Forms API

Forms API Documentation

Complete guide to integrating with Forms API

Get Started

Start with 100 free submissions

Quick Start

Forms API lets you collect form submissions without building backend infrastructure. Create forms, get an endpoint, and start collecting data in minutes.

1

Sign Up & Create Forms

Create your account and set up your forms from the dashboard.

2

Create a Form

Design your form in the dashboard or use one of our templates.

3

Submit Data

Use our API to submit form data and view submissions in your dashboard.

Submit Form API

Use this endpoint to submit data to your forms. Requires a valid Form ID and an active subscription.

POSThttps://apiforms.com/api/forms/submit

Authentication

No API key is required. Just include your formId in the request body.

Headers

Content-Type: application/json

Request Body

JSON Payload

{
  "formId": "YOUR_FORM_ID",
  "formData": {
    "name": "John Doe",
    "email": "john@example.com",
    "message": "Hello from Forms API!"
  }
}

Note: Replace YOUR_FORM_ID with your actual Form ID from the dashboard.

Response (Success)

200 OK

{
  "success": true,
  "remaining": 19
}

The remaining field shows how many submissions you have left in your current billing period.

Field Validation

The API enforces your form's schema server-side. A required field is rejected if its value is null, undefined, a whitespace-only string, or an empty array. For select and radio fields, the submitted value must match one of the field's defined options. Validation failures return a 400 with an array of error messages:

400 Validation Error

{
  "error": ["Name is required", "Plan must be one of Free, Pro, Enterprise"]
}

Error Handling

Error Response Format

Error Examples

// 400 - Bad Request
{ "error": "Missing fields" }

{ "error": ["Name is required", "Plan must be one of Free, Pro, Enterprise"] }

// 403 - Forbidden
{ "error": "This form is not currently accepting submissions.", "code": "SUBSCRIPTION_REQUIRED" }

{ "error": "This form restricts submissions to specific origins. Add your domain in the form settings.", "code": "ORIGIN_DENIED" }

{ "error": "Origin not allowed", "code": "ORIGIN_DENIED" }

{ "error": "Invalid origin", "code": "ORIGIN_DENIED" }

// 404 - Not Found
{ "error": "Form not found" }

// 410 - Gone
{ "error": "This form is no longer accepting submissions", "code": "FORM_ARCHIVED" }

// 429 - Too Many Requests
{ "error": "Submission limit exceeded (100). Upgrade your plan for more.", "code": "SUBSCRIPTION_LIMIT_EXCEEDED" }

{ "error": "Too many requests" }

// 500 - Internal Server Error
{ "error": "Server error" }

HTTP Status Codes

CodeDescription
200Success - Form submitted successfully
400Bad Request - Missing fields or validation failed
403Forbidden - Subscription inactive or origin denied
404Not Found - Form not found
410Gone - Form is archived
429Too Many Requests - Rate limit or submission limit exceeded
500Internal Server Error - Server error

Implementation Examples

cURL

Basic cURL Request

curl -X POST https://apiforms.com/api/forms/submit \
  -H "Content-Type: application/json" \
  -d '{
    "formId": "YOUR_FORM_ID",
    "formData": {
      "name": "John Doe",
      "email": "john@example.com",
      "message": "Hello from Forms API!"
    }
  }'

JavaScript (Node.js/Browser)

Using fetch()

const response = await fetch("https://apiforms.com/api/forms/submit", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    formId: "YOUR_FORM_ID",
    formData: {
      name: "John Doe",
      email: "john@example.com",
      message: "Hello from Forms API!"
    }
  })
});

const result = await response.json();
console.log(result);

Python

Using requests library

import requests

response = requests.post("https://apiforms.com/api/forms/submit", json={
    "formId": "YOUR_FORM_ID",
    "formData": {
        "name": "John Doe",
        "email": "john@example.com",
        "message": "Hello from Forms API!"
    }
})

result = response.json()
print(result)

PHP

Using cURL in PHP

<?php
$url = 'https://apiforms.com/api/forms/submit';
$data = [
    'formId' => 'YOUR_FORM_ID',
    'formData' => [
        'name' => 'John Doe',
        'email' => 'john@example.com',
        'message' => 'Hello from Forms API!'
    ]
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$result = json_decode($response, true);

echo json_encode($result, JSON_PRETTY_PRINT);
curl_close($ch);
?>

Need Help?

Our documentation covers the basics, but if you need help implementing Forms API or have questions about advanced features, we're here to help.