POST /v1/schemas
POST https://api.deskew.dev/v1/schemas
Stores a schema in the key’s project. Reference it from POST /v1/extract with schema=<name>. Requires extract:write. See the fields and schemas guide for how extraction uses it.
Request body
Section titled “Request body”application/json:
| Field | Type | Rules |
|---|---|---|
name |
string | 1–80 characters, [A-Za-z0-9_-] only. Reusing a name creates the next version |
json_schema |
object | A JSON Schema with "type": "object" at the top level |
Example
Section titled “Example”curl https://api.deskew.dev/v1/schemas \ -H "Authorization: Bearer $DESKEW_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "receipt-v1", "json_schema": { "type": "object", "properties": { "merchant": { "type": "string" }, "purchased_at": { "type": "string", "description": "ISO 8601 date-time" }, "total": { "type": "number", "description": "Total paid including tax" }, "currency": { "type": "string" }, "payment_method": { "type": "string", "enum": ["card", "cash", "other"] } }, "required": ["merchant", "total"] } }'r = requests.post(f"{API}/v1/schemas", headers=HEADERS, json={ "name": "receipt-v1", "json_schema": { "type": "object", "properties": { "merchant": {"type": "string"}, "purchased_at": {"type": "string", "description": "ISO 8601 date-time"}, "total": {"type": "number", "description": "Total paid including tax"}, "currency": {"type": "string"}, "payment_method": {"type": "string", "enum": ["card", "cash", "other"]}, }, "required": ["merchant", "total"], },})schema = r.json() # 201const res = await fetch(`${API}/v1/schemas`, { method: "POST", headers: { ...headers, "Content-Type": "application/json" }, body: JSON.stringify({ name: "receipt-v1", json_schema: { type: "object", properties: { merchant: { type: "string" }, purchased_at: { type: "string", description: "ISO 8601 date-time" }, total: { type: "number", description: "Total paid including tax" }, currency: { type: "string" }, payment_method: { type: "string", enum: ["card", "cash", "other"] }, }, required: ["merchant", "total"], }, }),});const schema = await res.json(); // 201Response
Section titled “Response”201 Created:
{ "id": "sch_01JE4KH8W9X0Y1Z2A3B4C5D6E7", "name": "receipt-v1", "version": 1, "json_schema": { "type": "object", "properties": { "merchant": { "type": "string" }, "purchased_at": { "type": "string", "description": "ISO 8601 date-time" }, "total": { "type": "number", "description": "Total paid including tax" }, "currency": { "type": "string" }, "payment_method": { "type": "string", "enum": ["card", "cash", "other"] } }, "required": ["merchant", "total"] }}Errors
Section titled “Errors”| Status | Code | When |
|---|---|---|
| 403 | insufficient_scope |
Key lacks extract:write |
| 422 | validation_error |
name malformed, json_schema missing, or json_schema.type is not object |
| 401 / 429 | Authentication, rate limit |