JSON Patch Apply API¶
Overview¶
Applies an RFC 6902 JSON Patch to a JSON document.
Endpoint¶
POST https://api.apidatatools.com/json-patch-apply-api
Authentication and input modes¶
Include x-api-key: YOUR_API_KEY. The x-source-type header supports body (default), url, and file; URL and file modes are asynchronous. Accepted extensions are .txt, .json, and .log.
Request body¶
Send document and a patch array. Supported operations are add, remove, replace, copy, move, and test.
{"document":{"active":false},"patch":[{"op":"replace","path":"/active","value":true}]}
curl example¶
curl -X POST 'https://api.apidatatools.com/json-patch-apply-api' \\
-H 'x-api-key: YOUR_API_KEY' \\
--data-raw '{"document":{"active":false},"patch":[{"op":"replace","path":"/active","value":true}]}'
URL and file mode examples¶
curl --request POST --url https://api.apidatatools.com/json-patch-apply-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-apply-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"}'
The referenced JSON must contain document and patch fields.
Success and async process¶
Body mode returns HTTP 200 with the patched JSON file and preview. URL/file mode returns HTTP 202 with status, job_id, status_url, and request_id. Poll GET /jobs/JOB_ID with the same API key. Queued/processing states include retry_after; success includes result; failure includes error.
{"status":"accepted","job_id":"JOB_ID","status_url":"https://api.apidatatools.com/jobs/JOB_ID","request_id":"REQUEST_ID"}
Error handling¶
Error details identify the patch operation index when applicable.
| HTTP status | Error codes |
|---|---|
400 | INVALID_SOURCE_TYPE, INVALID_BODY_ENCODING, EMPTY_BODY, INVALID_PATCH_BODY, INVALID_PATCH_OPERATION, UNSUPPORTED_PATCH_OPERATION, PATCH_TEST_FAILED, INVALID_JSON_POINTER, INVALID_ARRAY_INDEX, JSON_POINTER_NOT_FOUND |
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 requests may return URL/file validation errors, FILE_TOO_LARGE, CONFIG_ERROR, or PLAN_CONFIG_ERROR. Worker failures include DOWNLOAD_FAILED, UPLOAD_FAILED, and patch errors. Status errors include INVALID_JOB_ID, JOB_NOT_FOUND, FORBIDDEN, and DDB_ERROR.
Notes¶
Body mode is synchronous; URL/file modes are asynchronous. Honor retry_after. Output URLs are temporary and plan-dependent.