JSON Patch Generator API¶
Overview¶
Generates an RFC 6902 JSON Patch that transforms one JSON value into another.
Endpoint¶
POST https://api.apidatatools.com/json-patch-generator-api
Authentication¶
Include x-api-key: YOUR_API_KEY.
Input modes¶
Supports body, url, and file; body mode is synchronous.
Headers¶
| Header | Required | Default | Description |
|---|---|---|---|
x-api-key | Yes | — | API key. |
x-source-type | No | body | Input mode. |
Accepted file extensions¶
.txt, .json, and .log.
Request body¶
The root object must contain left and right JSON values.
{"left":{"name":"Ada","active":false},"right":{"name":"Ada","active":true}}
curl example¶
curl -X POST 'https://api.apidatatools.com/json-patch-generator-api' \\
-H 'x-api-key: YOUR_API_KEY' \\
--data-raw '{"left":{"active":false},"right":{"active":true}}'
Result¶
Produces an application/json-patch+json array. The example generates a replace operation for /active.
URL and file modes¶
URL mode sends {"url":"https://example.com/input.json"} and file mode sends {"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}. Set x-source-type to url or file.
curl --request POST --url https://api.apidatatools.com/json-patch-generator-api \
--header 'x-api-key: YOUR_API_KEY' --header 'x-source-type: url' \
--header 'Content-Type: application/json' --data '{"url":"https://example.com/input.json"}'
curl --request POST --url https://api.apidatatools.com/json-patch-generator-api \
--header 'x-api-key: YOUR_API_KEY' --header 'x-source-type: file' \
--header 'Content-Type: application/json' --data '{"file":"S3_KEY_RETURNED_BY_THE_UPLOAD_WORKFLOW"}'
Success and async process¶
Body mode returns HTTP 200 with an application/json-patch+json file and preview. URL/file mode returns HTTP 202:
{"status":"accepted","job_id":"JOB_ID","status_url":"https://api.apidatatools.com/jobs/JOB_ID","request_id":"REQUEST_ID"}
Poll the status URL with x-api-key. Queued/processing responses include message and retry_after; success contains result.file and result.preview; failure contains error.code, error.message, and error.details.
Error handling¶
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, INVALID_PATCH_BODY, INVALID_JSON, INVALID_JSON_ENCODING, JSON_TOO_DEEP |
401 | UNAUTHORIZED |
404 | USER_NOT_FOUND, UNKNOWN_FUNCTION |
413 | PAYLOAD_TOO_LARGE |
429 | QUOTA_EXCEEDED, RATE_LIMITED |
500 | PLAN_NOT_FOUND, AUTH_ERROR, INTERNAL_ERROR |
Async submission errors include input URL/file validation errors, FILE_TOO_LARGE, CONFIG_ERROR, and PLAN_CONFIG_ERROR. Processing errors include INVALID_JOB, DOWNLOAD_FAILED, UPLOAD_FAILED, and tool errors. Status errors include INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, and DDB_ERROR.
Notes¶
Body mode is synchronous. Honor retry_after; limits and temporary output retention depend on your plan.