Skip to main content

Response Formats

Success Response (201 Created)

When a submission is successfully created, you'll receive a 201 status code with submission details:

{
"message": "Data inserted successfully",
"submission": {
"id": 123,
"workflow_id": 1,
"user_id": 5,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
}

Success Response Fields

FieldDescription
messageConfirmation message
submission.idUnique submission identifier
submission.workflow_idID of the workflow that processed the submission
submission.user_idID of the API user who created the submission
submission.created_atISO timestamp when submission was created
submission.updated_atISO timestamp when submission was last modified

Error Responses

Validation Error (400 Bad Request)

Occurs when submitted data fails form validation:

{
"error": "Invalid input data: Validation failed for 'Email': The field must be a valid email address",
"code": "VALIDATION_ERROR"
}

Common Validation Errors

Error MessageCauseSolution
"Field 'name' is required"Missing required fieldAdd the required field to your request
"Invalid email format"Email field contains invalid emailUse proper email format (user@domain.com)
"Field exceeds maximum length"Text too longReduce text length to meet field limits
"Invalid date format"Date in wrong formatUse ISO date format (YYYY-MM-DD)
"Field must be a number"Non-numeric value in number fieldProvide numeric value

Authentication Error (401 Unauthorized)

Occurs when authentication fails:

{
"error": "Invalid or expired authentication token",
"code": "TOKEN_INVALID"
}

Authentication Error Codes

CodeDescriptionSolution
TOKEN_MISSINGNo Authorization headerAdd Bearer token to request headers
TOKEN_INVALIDInvalid or expired tokenVerify token is correct and user is active
USER_INACTIVEAPI user account disabledContact admin to activate account
GUARD_MISMATCHWrong user typeUse API user, not normal account

Authorization Error (403 Forbidden)

Occurs when user lacks permission or workflow is invalid:

{
"error": "This workflow is no longer valid",
"code": "WORKFLOW_NOT_AUTHORIZED"
}

Authorization Error Codes

CodeDescriptionSolution
WORKFLOW_NOT_AUTHORIZEDNo permission for workflowContact admin to grant workflow access
WORKFLOW_EXPIREDWorkflow past expiration dateUse active workflow or extend expiration
WORKFLOW_INACTIVEWorkflow is disabledActivate workflow or use different one
INSUFFICIENT_PERMISSIONSUser lacks required rolesContact admin to assign proper roles

Workflow Not Found (404 Not Found)

Occurs when workflow ID doesn't exist:

{
"error": "Workflow with ID 999 not found",
"code": "WORKFLOW_NOT_FOUND"
}

Rate Limit Error (429 Too Many Requests)

Occurs when rate limits are exceeded:

{
"error": "Daily API request limit exceeded for user",
"code": "USER_DAILY_LIMIT_EXCEEDED",
"retry_after": 1642204800
}

Rate Limit Error Codes

CodeDescriptionRetry Strategy
GLOBAL_MONTHLY_LIMIT_EXCEEDEDSystem-wide monthly limitWait until next month
USER_DAILY_LIMIT_EXCEEDEDUser's daily limit reachedWait until next day
IP_HOURLY_LIMIT_EXCEEDEDIP address hourly limitWait one hour or use different IP

Server Error (500 Internal Server Error)

Occurs when server encounters unexpected error:

{
"error": "Internal server error occurred while processing submission",
"code": "INTERNAL_ERROR"
}

Response Headers

Rate Limit Headers

All responses include rate limiting information:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1642204800
HeaderDescription
X-RateLimit-LimitMaximum requests allowed in current window
X-RateLimit-RemainingNumber of requests remaining
X-RateLimit-ResetUnix timestamp when limit resets

Content Headers

Content-Type: application/json
Content-Length: 156

Error Handling Best Practices

1. Check HTTP Status Codes

if (response.status === 201) {
// Success - process submission data
console.log('Submission created:', response.data.submission.id);
} else if (response.status === 400) {
// Validation error - fix data and retry
console.error('Validation failed:', response.data.error);
} else if (response.status === 401) {
// Authentication error - check token
console.error('Authentication failed:', response.data.error);
} else if (response.status === 429) {
// Rate limit - implement retry with backoff
console.warn('Rate limited, retry after:', response.data.retry_after);
}

2. Parse Error Messages

function parseValidationError(errorMessage) {
// Extract field name and specific error
const match = errorMessage.match(/Validation failed for '(.+?)': (.+)/);
if (match) {
return {
field: match[1],
message: match[2]
};
}
return { field: 'unknown', message: errorMessage };
}

3. Implement Retry Logic

async function submitWithRetry(data, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
const response = await submitData(data);
return response;
} catch (error) {
if (error.response?.status === 429 && i < maxRetries - 1) {
// Rate limited - wait and retry
const retryAfter = error.response.data.retry_after || Math.pow(2, i) * 1000;
await sleep(retryAfter);
continue;
} else if (error.response?.status >= 500 && i < maxRetries - 1) {
// Server error - retry with exponential backoff
await sleep(Math.pow(2, i) * 1000);
continue;
}
throw error; // Don't retry for client errors (4xx)
}
}
}

4. Log Responses for Debugging

function logApiResponse(response, requestData) {
const logData = {
timestamp: new Date().toISOString(),
status: response.status,
requestData: requestData,
responseData: response.data,
rateLimitRemaining: response.headers['x-ratelimit-remaining']
};

if (response.status >= 400) {
console.error('API Error:', logData);
} else {
console.log('API Success:', logData);
}
}

Response Validation

Validate Success Response

function validateSuccessResponse(response) {
if (!response.data.submission) {
throw new Error('Invalid success response: missing submission data');
}

if (!response.data.submission.id) {
throw new Error('Invalid success response: missing submission ID');
}

return response.data.submission;
}

Handle Partial Failures

Some complex submissions might partially succeed:

function handlePartialFailure(response) {
if (response.data.warnings) {
console.warn('Submission created with warnings:', response.data.warnings);
}

if (response.data.skipped_fields) {
console.info('Some fields were skipped:', response.data.skipped_fields);
}

return response.data.submission;
}

Testing Response Handling

Mock Different Response Types

// Test success response
const mockSuccess = {
status: 201,
data: {
message: "Data inserted successfully",
submission: { id: 123, workflow_id: 1, user_id: 5 }
}
};

// Test validation error
const mockValidationError = {
status: 400,
data: {
error: "Validation failed for 'email': Invalid email format",
code: "VALIDATION_ERROR"
}
};

// Test rate limit error
const mockRateLimit = {
status: 429,
data: {
error: "Daily limit exceeded",
code: "USER_DAILY_LIMIT_EXCEEDED",
retry_after: 86400
}
};

Understanding these response formats helps you build robust integrations that handle both success and error scenarios gracefully.