JSON Schema Generator API¶
Overview¶
Accepts JSON text and processes it to generate a schema. Body mode runs synchronously; URL and file modes submit an asynchronous job.
Endpoint¶
| Property | Value |
|---|---|
| Method | POST |
| URL | https://api.apidatatools.com/json-schema-generator-api |
Authentication¶
Include your API key in the x-api-key header:
x-api-key: YOUR_API_KEY
Input modes¶
| Mode | Behavior |
|---|---|
body | Synchronous processing of text in the request body. |
url | Asynchronous processing of a file at a URL. |
file | Asynchronous processing of a previously uploaded file. |
Headers¶
Header names are case-insensitive. Use the lowercase spellings shown here.
| Header | Type | Required | Default / values | Description |
|---|---|---|---|---|
x-api-key | string | Yes | Your API key | Authenticates the request. |
x-source-type | string | No | Default: body. Values: body, url, file | Selects the input mode. |
Accepted file extensions¶
URL and file modes accept these input extensions:
.txt.json.log
Request body¶
Body mode¶
Send the JSON text to process as raw text in the request body. The request body must not be empty.
URL mode¶
Send a JSON object containing the file URL:
{
"url": "https://example.com/input.json"
}
The URL must be valid HTTP or HTTPS and reachable by the service.
File mode¶
Send a JSON object containing the exact storage key returned by the upload workflow:
{
"file": "S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"
}
curl examples¶
Body mode¶
curl -X POST "https://api.apidatatools.com/json-schema-generator-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: body" \
--data-raw '{"name":"Ada","active":true}'
URL mode¶
curl -X POST "https://api.apidatatools.com/json-schema-generator-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: url" \
-H "Content-Type: application/json" \
--data '{"url":"https://example.com/input.json"}'
File mode¶
curl -X POST "https://api.apidatatools.com/json-schema-generator-api" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-source-type: file" \
-H "Content-Type: application/json" \
--data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success responses¶
Synchronous body mode¶
A successful synchronous response is HTTP 200. A data-producing response has this shape; preview is serialized JSON:
{
"request_id": "REQUEST_ID",
"status": "success",
"preview": "SERIALIZED_JSON"
}
A file-producing response has this shape:
{
"request_id": "REQUEST_ID",
"status": "success",
"file": "TEMPORARY_DOWNLOAD_URL",
"preview": "OUTPUT_PREVIEW"
}
The response shape depends on the result produced. Download URLs are temporary; retention depends on your plan.
Asynchronous URL and file modes¶
A successful job submission returns HTTP 202:
{
"status": "accepted",
"job_id": "JOB_ID",
"status_url": "https://api.apidatatools.com/jobs/JOB_ID",
"request_id": "REQUEST_ID"
}
Async job status¶
Check a submitted job with:
curl -X GET "https://api.apidatatools.com/jobs/JOB_ID" \
-H "x-api-key: YOUR_API_KEY"
The status response includes request_id, job_id, status, created_at, and updated_at.
For queued and processing jobs, the response also includes:
{
"message": "Your job is being processed.",
"retry_after": 2
}
For a successful job, the response includes result, containing the job result:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "success",
"created_at": 0,
"updated_at": 0,
"result": {
"status": "success",
"file": "TEMPORARY_DOWNLOAD_URL",
"preview": "OUTPUT_PREVIEW"
}
}
For a failed job, the response includes error with the error code, message, and details:
{
"request_id": "REQUEST_ID",
"job_id": "JOB_ID",
"status": "failed",
"created_at": 0,
"updated_at": 0,
"error": {
"code": "ERROR_CODE",
"message": "Error message",
"details": {
"message": "Error message"
}
}
}
Error handling¶
Errors use this envelope. details may include additional fields.
{
"status": "error",
"error": "ERROR_CODE",
"request_id": "REQUEST_ID",
"details": {
"message": "Error message"
}
}
Request and authentication errors¶
| HTTP status | Error code | When it can occur |
|---|---|---|
400 | INVALID_SOURCE_TYPE | x-source-type is not body, url, or file. |
400 | INVALID_BODY_ENCODING | The request body cannot be decoded. |
400 | EMPTY_BODY | The request body is empty. |
400 | Tool-specific error | Synchronous processing returns a tool execution error. |
401 | UNAUTHORIZED | Authentication is missing or unauthorized. |
404 | USER_NOT_FOUND | The authenticated user cannot be found. |
404 | UNKNOWN_FUNCTION | The requested API endpoint is unsupported. |
413 | PAYLOAD_TOO_LARGE | The request body exceeds the limit for the plan. |
429 | QUOTA_EXCEEDED | The plan’s monthly request quota is exhausted. |
429 | RATE_LIMITED | The request rate exceeds the plan’s limit. |
500 | PLAN_NOT_FOUND | Plan configuration cannot be found. |
500 | INTERNAL_ERROR | An unexpected processing error occurs. |
Asynchronous submission errors¶
| HTTP status | Error code | When it can occur |
|---|---|---|
400 | INVALID_BODY | The request is not valid JSON or is not a JSON object. |
400 | INVALID_URL | The URL is missing, invalid, or not HTTP/HTTPS. |
400 | URL_UNREACHABLE | The service cannot reach the URL. |
400 | URL_NOT_OK | The URL check returns a status other than 200 or 206. |
400 | INVALID_FILE | The file reference is missing or invalid. |
400 | FILE_UNAVAILABLE | The referenced file cannot be accessed. |
400 | INVALID_FILE_EXTENSION | The input extension is unsupported. |
400 | INVALID_SOURCE_TYPE | The asynchronous handler receives a source type other than url or file. |
413 | FILE_TOO_LARGE | The input exceeds the effective file limit for the plan. |
500 | CONFIG_ERROR | Required job-processing configuration is unavailable. |
500 | PLAN_CONFIG_ERROR | The plan’s file-limit configuration is invalid. |
Job-status errors¶
The status endpoint reports these errors with HTTP 400 when returned by the status handler:
| Error code | When it can occur |
|---|---|
INVALID_JOB_ID | The job ID is missing. |
JOB_NOT_FOUND | The job cannot be found. |
FORBIDDEN | The job does not belong to the authenticated user. |
DDB_ERROR | The status handler cannot query the job. |
Asynchronous processing failures, including DOWNLOAD_FAILED, UPLOAD_FAILED, FILE_TOO_LARGE, and INTERNAL_ERROR, are reported in the job’s failed status response.
Notes¶
- Body-size, file-size, quota, rate, and retention limits depend on your plan. See tool limits.
- Download URLs are temporary, and their retention period depends on your plan.
- URL and file modes accept only the extensions listed above.