MENU navbar-image

Introduction

Public REST API for Contract creation and Electronic Signature lifecycle. Bilingual (fa/en) errors. RFC 7807 problem+json envelope.

## Quickstart

1. **Create a Personal Access Token** in your Emza dashboard at `/dashboard/api-tokens`. The plain token is shown **once at creation** — copy and store it securely.
2. The token format is `{id}|{secret}` (Sanctum Personal Access Token), e.g. `42|abcdef1234567890…`. Send it verbatim — no `pat_live_` prefix, no extra wrapping.
3. Send any API request with `Authorization: Bearer 42|abcdef1234567890…`.
4. Your token's **mode** (Live vs. Test/Sandbox) is shown in the `data.token.mode` field of `GET /api/v1/me`. Sandbox tokens never charge your wallet — usage is no-op.

## Headers

| Header | Purpose |
|--------|---------|
| `Authorization: Bearer <token>` | Required on all authenticated routes |
| `Idempotency-Key: <key>` | Required on every POST/PATCH/DELETE (see Idempotency section) |
| `Accept: application/json` | Recommended; ensures JSON responses on all paths |
| `X-Skip-Sms: true` | (POST /contracts, POST /contracts/{code}/signers) you deliver `signing_url` yourself: for that contract we send no signing-link SMS or email and no signer reminders. An explicit `POST …/signers/{slug}/resend` still sends. The verification-code SMS on the signing page is always sent (it proves the signer holds the phone). |

## Idempotency

All `POST`, `PATCH`, `PUT`, `DELETE` endpoints support **Idempotency-Key** for safe retries.

- **Format:** `[A-Za-z0-9_-]+`, max 64 chars (e.g. `pay-2026-05-13-001` or any ULID).
- **TTL:** 24 hours. Within that window, replaying the same key + same body returns the **original response** with `X-Idempotent-Replay: true` (status code preserved).
- **Not stored — retry with the same key:** errors about your account's current state, such as `402 insufficient_balance` (top up the wallet), `403 account_verification_required` / `account_verification_expired` or `422 legal_entity_board_expired`, are not cached, and neither are answers that ask you to try again shortly (`409 contract_busy`, every `429`, every `5xx`) — fix the cause, then retry with the same key and body; the request runs again.
- **Body conflict:** Same key with a different body returns `409 idempotency_conflict`.
- **Malformed key:** 65+ chars or characters outside `[A-Za-z0-9_-]` returns `400 malformed_idempotency_key`.
- **Missing key:** Allowed for backwards compat — request proceeds without replay protection. Recommended to always send one.

## Rate limits

Per-token, tier-aware. Every response includes `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset` headers. When exceeded, the response is `429 rate_limit_exceeded` with `Retry-After` header.

| Tier | Requests / minute |
|------|------:|
| Anonymous (`/health`, signed download URL) | 60 (per IP) |
| Free / no active package | 30 (per token) |
| Bronze | 120 |
| Silver | 600 |
| Gold | 3,000 |

## Response envelope

**Success** — wrapped in `data`:
```json
{ "data": { ... } }
```
Paginated lists add `meta` + `links`:
```json
{
  "data": [...],
  "meta": { "current_page": 1, "per_page": 20, "total": 142 },
  "links": { "next": "https://elemza.com/api/v1/contracts?page=2" }
}
```

**Error** — RFC 7807 problem+json envelope with bilingual titles:
```json
{
  "type": "https://docs.elemza.com/errors/token_invalid",
  "status": 401,
  "code": "token_invalid",
  "title_fa": "توکن نامعتبر است",
  "title_en": "Invalid token",
  "request_id": "01KRH69QCTCWD0RWP2NRR05VZ5"
}
```

Field semantics:

- `type` — stable URI identifying the error class. Treat as constant; UI may follow for help docs.
- `status` — HTTP status code (duplicates the response line; convenient for log pipelines).
- `code` — machine-readable error identifier. **Always present.** Use this for branching.
- `title_fa` / `title_en` — human-readable message in both languages. Safe to display directly to end-users.
- `request_id` — ULID echoed in `X-Request-ID` response header. Quote this when contacting support.

Validation errors additionally include `errors` (field-keyed array of messages):
```json
{
  "status": 422, "code": "validation",
  "errors": { "url": ["فقط آدرس‌های HTTPS مجاز هستند."] },
  ...
}
```

## Error codes catalog

| code | HTTP | Meaning |
|------|:----:|---------|
| `token_missing` | 401 | `Authorization: Bearer …` header is missing or empty |
| `token_invalid` | 401 | Token doesn't match any active row (typo, deleted, malformed) |
| `token_revoked` | 401 | Token was revoked (manually or auto after 5 IP-whitelist strikes) |
| `token_expired` | 401 | Token's `expires_at` is in the past |
| `token_missing` | 401 | No `Authorization: Bearer` header was sent |
| `ip_not_allowed` | 403 | Request IP doesn't match the token's IP whitelist |
| `scope_missing` | 403 | Token lacks the ability needed for this endpoint (e.g. `signers:read_pii` for PII filters) |
| `policy_denied` | 403 | Authenticated but not authorized for this specific resource |
| `not_found` | 404 | Resource doesn't exist, was deleted, or isn't owned by the caller |
| `method_not_allowed` | 405 | HTTP method not supported on this path |
| `insufficient_balance` | 402 | Wallet balance too low for the requested operation |
| `idempotency_conflict` | 409 | Idempotency-Key was already used with a different request body |
| `idempotency_in_progress` | 409 | A concurrent request with the same Idempotency-Key is still processing; retry shortly |
| `validation` | 422 | Body or query parameters failed validation (see `errors` field) |
| `invalid_page` | 422 | Requested page number is out of range |
| `invalid_format` | 422 | A `format`/option parameter had an unsupported value |
| `not_ready` | 422 | The requested artifact (e.g. signed PDF) is not generated yet |
| `malformed_idempotency_key` | 400 | Idempotency-Key value has wrong format |
| `rate_limit_exceeded` | 429 | Tier limit reached. Retry after `Retry-After` seconds |
| `preview_not_available` | 501 | Endpoint is a documented stub not yet implemented (e.g. template page preview) |
| `internal_error` | 500 | Unexpected server fault. `request_id` is logged on our side; report when frequent |

## Webhooks

Subscribe to async events via `POST /webhooks`. We deliver an HTTP `POST` to your URL with an HMAC-SHA256 signature: `X-Emza-Timestamp: <unix seconds>` and `X-Emza-Signature: sha256=<hex>`, where `<hex>` is `HMAC-SHA256(secret, "<timestamp>.<raw body>")` — the timestamp header, a dot, then the request body exactly as received. Compare in constant time and reject a timestamp older than five minutes.

**Event names** (set in `events` array; use `["*"]` for all):

| Event | When |
|-------|------|
| `contract.created` | Contract record created (before file processing) |
| `contract.processing.completed` | Background file → PDF job finished |
| `contract.processing.failed` | File processing failed; reason in payload |
| `contract.signer.added` | New signer attached to contract |
| `contract.signer.authenticated` | Signer completed OTP / KYC |
| `contract.signer.signed` | Signer placed signature/stamp |
| `contract.signer.rejected` | Signer canceled their participation |
| `contract.completed` | All signers signed + signed PDF generated |
| `contract.canceled` | Owner canceled the contract |
| `contract.voided` | Owner withdrew the contract after at least one signature (`reason`: `withdrawn_by_sender`). `contract.canceled` fires too, with the same `reason`, so older integrations still learn it ended |
| `contract.refunded` | Cost refunded to wallet (auto on cancel). One event per cancel: `amount` is the total refunded now; when it was more than one payment (an electronic replacement carrying the replaced contract's payment) `parts` lists each — `transaction_id`, `amount`, `wallet_balance_after`, `paid_for_code` — and `transaction_id` / `wallet_balance_after` are the first part's |
| `contract.signing_deadline.passed` | The signing deadline passed: `outcome` = `canceled` (nobody had signed) or `closed` (signing stopped until the owner extends) |
| `contract.amendment.completed` | Every party signed an amendment (الحاقیه) attached to this contract; payload names the parent |
| `contract.rescinded` | Every party signed a full rescission (اقاله): the contract stays `completed`, `rescinded_at` is set |

**URL restrictions (SSRF guard):** webhook URLs are validated server-side before save. The following are rejected with `422`:

- Non-HTTPS schemes (`http://`, `ftp://`, `javascript:`, `file://`)
- Loopback IPs (`127.0.0.0/8`, `::1`)
- RFC 1918 private (`10/8`, `172.16/12`, `192.168/16`)
- Link-local + cloud metadata (`169.254.0.0/16`, `100.100.100.200`)
- IPv6 link-local (`fe80::/10`) and unique-local (`fc00::/7`)
- Hostnames ending in `.local`, `.internal`, `.private`, `.lan`, or `localhost`
- Hosts whose DNS resolves to any of the above

**Verifying signatures:** see `app/Services/Webhook/` examples or the Webhook section below.

<aside>Full architecture + decision log lives at <code>docs/api-master-plan/</code> in the Emza repo. Stakeholder-locked plan as of 2026-05-11.</aside>

Authenticating requests

To authenticate requests, include an Authorization header with the value "Bearer 42|abcdef1234567890abcdef1234567890abcdef".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

Create your token in the dashboard at /dashboard/api-tokens. The plain token is shown once at creation. Format is {id}|{secret} — send it verbatim in the Authorization header, no patlive prefix.

Companies

Check a counterparty company before you send (Jibit P7, P6-P7-P16 design §6.3).

Check a company signer

requires authentication

Asks the companies registry, before you add a company signer, for the company's official name and state and whether the person who will sign for it is on its current board. Changes nothing (no idempotency key). Every answer — free or paid — counts toward 50 checks a day per account (429 preflight_daily_cap). You see one of three outcomes for the person: no_warning, not_on_board or not_checked; signer_basis is added only when your account is an active representative of that company. A test token answers not_checked (test_mode). When the registry service is not available: 503 inquiry_temporarily_unavailable with Retry-After, or 403 inquiry_not_available.

Scope: signers:write.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/companies/check" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"legal_national_code\": \"14001234567\",
    \"signer_national_code\": \"0012345678\"
}"
const url = new URL(
    "https://elemza.com/api/v1/companies/check"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "legal_national_code": "14001234567",
    "signer_national_code": "0012345678"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "data": {
        "legal_national_code": "140****4567",
        "registry_name": "آرین تجارت پارس",
        "status": "active",
        "status_fa": "فعال",
        "signer_check": "not_on_board",
        "checked_at": "2026-11-06T10:22:00.000000Z",
        "warnings": [
            {
                "code": "signer_not_on_board",
                "severity": "high",
                "title_fa": "این شخص در فهرستِ فعلیِ هیئت‌مدیرهٔ این شرکت نیست.",
                "title_en": "This person is not on the company's current board."
            }
        ]
    }
}
 

Example response (422):


{
    "status": 422,
    "code": "validation",
    "title_fa": "مقادیر ارسالی نامعتبر است",
    "title_en": "Request body validation failed"
}
 

Example response (429):


{
    "status": 429,
    "code": "preflight_daily_cap",
    "title_fa": "سقفِ روزانهٔ سنجشِ شرکت برای این حساب پر شده است.",
    "title_en": "The daily company-check limit for this account is reached."
}
 

Example response (503):


{
    "status": 503,
    "code": "inquiry_temporarily_unavailable",
    "title_fa": "این استعلام الان در دسترس نیست؛ کمی بعد دوباره امتحان کنید.",
    "title_en": "This inquiry is temporarily unavailable."
}
 

Request      

POST api/v1/companies/check

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

legal_national_code   string     

The company's 11-digit national ID. Example: 14001234567

signer_national_code   string  optional    

The national code of the person who will sign for the company. Example: 0012345678

Contracts

Public signed-URL download.

requires authentication

Validates Laravel's signed middleware. No Bearer token required — the URL signature is the auth proof. The signature is generated by downloadPdf() after the bearer was verified, so this is functionally equivalent to a 24h time-bounded capability URL.

Records an ApiRequestLog-style entry via the underlying ContractDownload audit table (same trail as the user-panel signed-link download flow).

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/contracts/architecto/dl" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/dl"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG8TPHX5KAGZGRCCXFBXN
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG8TPHX5KAGZGRCCXFBXN"
}
 

Request      

GET api/v1/contracts/{code}/dl

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char public code. Example: architecto

List contracts

requires authentication

Returns the paginated contracts the token's user may see:

With scope=org, a member whose organisation owner has granted them «see the organisation's contracts» also receives the owner's and every other member's contracts, under the same two exclusions. Without that permission scope=org changes nothing and is not an error. The default (no scope) never widens, so an existing «my contracts» sync keeps receiving exactly what it received before the permission was granted.

Scope: contracts:read.

PII filter scope requirement: filtering by signer_mobile or signer_national_code requires the additional signers:read_pii ability on your token. Without it, those query parameters return 403 scope_missing. This prevents a low-privilege contracts:read token from using the index as a confirmation oracle to check whether a given mobile/national-code signs any contract on the owner's tree.

The * wildcard scope also passes the check.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/contracts?status=waiting_signature&signature_method=digital&created_after=2026-01-01T00%3A00%3A00Z&created_before=architecto&signer_mobile=09121234567&signer_national_code=architecto&template_id=16&is_private=&scope=org&role=sent&q=%D8%A7%D8%AC%D8%A7%D8%B1%D9%87&waiting_over_days=7&updated_since=2026-10-23T08%3A30%3A00Z&ends_before=1405%2F09%2F30&ends_after=1405%2F07%2F01&counterparty=%D8%A2%D9%84%D9%81%D8%A7&type=%D8%A7%D8%AC%D8%A7%D8%B1%D9%87%0A%0A%60signer_mobile%60%2C+%60signer_national_code%60%2C+%60counterparty%60%2C+%60type%60%2C+%60ends_before%60+and+%60ends_after%60+ask+about+what%0Athe+SENDER+holds%2C+so+they+only+ever+match+contracts+you+sent+%28or+see+through+your+company+or+organisation%29%3A%0Aa+contract+you+only+sign+is+left+out+of+a+list+filtered+on+any+of+them.&page=16&per_page=16&sort=architecto" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"status\": \"draft\",
    \"signature_method\": \"electronic\",
    \"created_after\": \"2026-11-19T06:39:47\",
    \"created_before\": \"2026-11-19T06:39:47\",
    \"signer_mobile\": \"09564255931\",
    \"signer_national_code\": \"ikhwaykcmy\",
    \"template_id\": 16,
    \"is_private\": true,
    \"scope\": \"org\",
    \"page\": 22,
    \"per_page\": 7,
    \"sort\": \"-created_at\",
    \"role\": \"received\",
    \"q\": \"z\",
    \"waiting_over_days\": 17,
    \"updated_since\": \"i\",
    \"ends_before\": \"yvdljnikhwaykcmy\",
    \"ends_after\": \"uwpwlvqwrsitcpsc\",
    \"counterparty\": \"q\",
    \"type\": \"l\"
}"
const url = new URL(
    "https://elemza.com/api/v1/contracts"
);

const params = {
    "status": "waiting_signature",
    "signature_method": "digital",
    "created_after": "2026-01-01T00:00:00Z",
    "created_before": "architecto",
    "signer_mobile": "09121234567",
    "signer_national_code": "architecto",
    "template_id": "16",
    "is_private": "0",
    "scope": "org",
    "role": "sent",
    "q": "اجاره",
    "waiting_over_days": "7",
    "updated_since": "2026-10-23T08:30:00Z",
    "ends_before": "1405/09/30",
    "ends_after": "1405/07/01",
    "counterparty": "آلفا",
    "type": "اجاره

`signer_mobile`, `signer_national_code`, `counterparty`, `type`, `ends_before` and `ends_after` ask about what
the SENDER holds, so they only ever match contracts you sent (or see through your company or organisation):
a contract you only sign is left out of a list filtered on any of them.",
    "page": "16",
    "per_page": "16",
    "sort": "architecto",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "draft",
    "signature_method": "electronic",
    "created_after": "2026-11-19T06:39:47",
    "created_before": "2026-11-19T06:39:47",
    "signer_mobile": "09564255931",
    "signer_national_code": "ikhwaykcmy",
    "template_id": 16,
    "is_private": true,
    "scope": "org",
    "page": 22,
    "per_page": 7,
    "sort": "-created_at",
    "role": "received",
    "q": "z",
    "waiting_over_days": 17,
    "updated_since": "i",
    "ends_before": "yvdljnikhwaykcmy",
    "ends_after": "uwpwlvqwrsitcpsc",
    "counterparty": "q",
    "type": "l"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG8YDY0XXC1SRA382NZ0D
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG8YDY0XXC1SRA382NZ0D"
}
 

Example response (403, PII filter without scope):


{
    "type": "https://docs.elemza.com/errors/scope_missing",
    "status": 403,
    "code": "scope_missing",
    "title_fa": "این فیلتر نیاز به مجوز signers:read_pii دارد",
    "title_en": "This filter requires the signers:read_pii scope",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS"
}
 

Request      

GET api/v1/contracts

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

status   string  optional    

Filter by status: draft|waiting_signature|completed|voided|canceled. Example: waiting_signature

signature_method   string  optional    

Filter by signing method: electronic|digital. Example: digital

created_after   string  optional    

ISO 8601 datetime. Example: 2026-01-01T00:00:00Z

created_before   string  optional    

ISO 8601 datetime. Example: architecto

signer_mobile   string  optional    

Iran mobile regex 09XXXXXXXXX. Requires signers:read_pii scope. Example: 09121234567

signer_national_code   string  optional    

10-digit Iran national code. Requires signers:read_pii scope. Example: architecto

template_id   integer  optional    

Filter by template. Example: 16

is_private   boolean  optional    

Filter by privacy flag. Example: false

scope   string  optional    

Only accepted value: org. Adds the contracts of your organisation's owner and of every member (never private ones, never ones in a company's name), when the owner has granted you «see the organisation's contracts». Without that permission it returns the same list as no scope. Example: org

role   string  optional    

Narrows the list to one side of the contract: sent — contracts you created (with scope=org: also those created by the members that scope shows you); received — contracts in which you are a signer and which you did not create; all — the default, exactly the list without role. Example: sent

q   string  optional    

Part of the title (1..120 chars), case-insensitive; Arabic «ي/ك» and Persian «ی/ک» are treated as the same letter, and %/_ are literal characters. Example: اجاره

waiting_over_days   integer  optional    

Contracts still waiting_signature whose signers were added more than this many days ago (1..3650). Example: 7

updated_since   string  optional    

ISO 8601 instant with an offset (2026-10-23T08:30:00Z, …+03:30) or a date (2026-10-23, the start of that day in Tehran time); contracts whose updated_at is at or after it. Note: a signer signing does not by itself change a contract's updated_at. Example: 2026-10-23T08:30:00Z

ends_before   string  optional    

Declared end date (facts.end_date) on or before this day. Jalali 1405/08/01 (Persian digits accepted) or ISO 2026-10-23; any other shape is 422 — a Jalali year written with dashes is refused, never shifted. Example: 1405/09/30

ends_after   string  optional    

Declared end date on or after this day; same formats as ends_before. Example: 1405/07/01

counterparty   string  optional    

Part of the declared counterparty name (facts.counterparty_name), case-insensitive. Example: آلفا

type   string  optional    

The declared contract type (facts.contract_type), whole value, case-insensitive. Example: `اجاره

signer_mobile, signer_national_code, counterparty, type, ends_before and ends_after ask about what the SENDER holds, so they only ever match contracts you sent (or see through your company or organisation): a contract you only sign is left out of a list filtered on any of them.`

page   integer  optional    

Default 1. Example: 16

per_page   integer  optional    

Max 100. Default 20. Example: 16

sort   string  optional    

created_at | -created_at | completed_at | -completed_at. Default -created_at. Example: architecto

Body Parameters

status   string  optional    

Example: draft

Must be one of:
  • draft
  • waiting_signature
  • completed
  • voided
  • canceled
signature_method   string  optional    

Example: electronic

Must be one of:
  • electronic
  • digital
created_after   string  optional    

value یک تاریخ معتبر نیست. Example: 2026-11-19T06:39:47

created_before   string  optional    

value یک تاریخ معتبر نیست. Example: 2026-11-19T06:39:47

signer_mobile   string  optional    

Must match the regex /^09[0-9]{9}$/. Example: 09564255931

signer_national_code   string  optional    

value باید 10 کاراکتر باشد. Example: ikhwaykcmy

template_id   integer  optional    

Example: 16

is_private   boolean  optional    

Example: true

scope   string  optional    

Example: org

Must be one of:
  • org
page   integer  optional    

value باید حداقل 1 باشد. Example: 22

per_page   integer  optional    

value باید حداقل 1 باشد. value نباید بیشتر از 100 باشد. Example: 7

sort   string  optional    

Example: -created_at

Must be one of:
  • created_at
  • -created_at
  • completed_at
  • -completed_at
role   string  optional    

── MCP W1-API (05 §7) — every one optional; absent ⇒ the list is exactly as before ──. Example: received

Must be one of:
  • sent
  • received
  • all
q   string  optional    

value باید حداقل 1 کاراکتر باشد. value نباید بیشتر از 120 کاراکتر باشد. Example: z

waiting_over_days   integer  optional    

value باید حداقل 1 باشد. value نباید بیشتر از 3650 باشد. Example: 17

updated_since   string  optional    

value نباید بیشتر از 40 کاراکتر باشد. Example: i

ends_before   string  optional    

value نباید بیشتر از 20 کاراکتر باشد. Example: yvdljnikhwaykcmy

ends_after   string  optional    

value نباید بیشتر از 20 کاراکتر باشد. Example: uwpwlvqwrsitcpsc

counterparty   string  optional    

value باید حداقل 1 کاراکتر باشد. value نباید بیشتر از 200 کاراکتر باشد. Example: q

type   string  optional    

value باید حداقل 1 کاراکتر باشد. value نباید بیشتر از 64 کاراکتر باشد. Example: l

Get contract

requires authentication

Returns full contract shape with embedded signers, per-page geometry, and template positions snapshot.

Scope: contracts:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/contracts/ABC1234567XYZ890" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/contracts/ABC1234567XYZ890"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG8ZX94862188Q12E80ZJ
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG8ZX94862188Q12E80ZJ"
}
 

Request      

GET api/v1/contracts/{code}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char public code (A-Z, 0-9). Example: ABC1234567XYZ890

Download signed PDF

requires authentication

Returns the final signed PDF in one of three formats (Phase 3):

Scope: contracts:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/contracts/architecto/pdf?format=url&ttl=16" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/pdf"
);

const params = {
    "format": "url",
    "ttl": "16",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG90BPSV23D8MVNN9X59C
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG90BPSV23D8MVNN9X59C"
}
 

Request      

GET api/v1/contracts/{code}/pdf

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char public code. Example: architecto

Query Parameters

format   string  optional    

redirect|url|stream. Default redirect. Example: url

ttl   integer  optional    

Signed URL lifetime in seconds (60..86400). Default 86400. Ignored when format=stream. Example: 16

Poll processing status

requires authentication

Lightweight (<200 bytes) status of the rasterization + signer-creation job.

🩸 THIS DOCBLOCK USED TO SAY «no DB hit», AND THAT WAS FALSE — corrected 2026-08-31. It reads one SELECT for the contract, ContractPolicy::view() then calls $user->hasRole([...]), and the outermost middleware on this route (App\Http\Middleware\Api\LogApiRequest) writes a synchronous INSERT into api_request_logs. So the honest description is: at least two reads and one write, per poll, and the load-lab measured this single endpoint taking 84.9% of all server time in a saturation run (1,494 calls at a fixed 1.5 s interval).

That mattered more than a wrong sentence usually does: a session reading «no DB hit» concludes this endpoint is already cheap and never looks at the expensive part, which is not in this controller at all.

Two things went the same day: the withCount('signers') this query used to carry — a correlated sub-SELECT on every poll whose result the JSON below never returned — and the two redundant single-column indexes on api_request_logs.

Step values: files, signers, sms, done, error.

Returns ready=true when step=done. If progress key is gone (TTL expired) and contract has signers + pages, falls back to ready=true (job finished earlier and key was reaped).

🔑 An integrator polling this in a loop is doing it the expensive way. The contract.processing.completed webhook fires from the same moment (ProcessContractFilesJob → ContractProcessingCompletedApiEvent → FanOutContractProcessingCompleted) and removes the loop entirely.

Scope: contracts:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/contracts/architecto/processing" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/processing"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG90TR4QAYYVF30NAAVSA
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG90TR4QAYYVF30NAAVSA"
}
 

Request      

GET api/v1/contracts/{code}/processing

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char contract code. Example: architecto

Create contract

requires authentication

Creates a new contract. Two modes:

One-shot — multipart/form-data with file field + metadata. File is persisted to staging and ProcessContractFilesJob is dispatched. Optional signers[] are added by the same job after page rasterization completes. Response is 202 Accepted; poll _links.processing until ready=true.

Multi-step — JSON without file. Creates a draft contract row only. Caller then issues POST /contracts/{code}/files to attach the document. Until it is attached the contract cannot be sent: POST /contracts/{code}/signers answers 422 document_required and adds, charges and texts nothing. After the upload, wait until GET /contracts/{code}/processing answers ready=true (or the contract.processing.completed webhook) and then add the signers — the signing SMS does not wait for the pages. To skip the wait, send signers inline with the file in one call.

Signature placement — template_id + template_enforcement

Passing template_id snapshots that template's signature slots onto the new contract. template_enforcement decides what those slots MEAN to the signer:

strict / loose are accepted as legacy aliases of locked / suggested (the spelling earlier revisions of this page advertised).

If the template pins slots on more than one page, send all_pages_signature=true as well — otherwise one signature on any allowed page completes the contract.

locked fixes WHERE each mark goes; by itself it does not make the signer use every slot — one signature is enough and a pinned stamp, name or date slot may stay empty. Send require_all_placements=true to make every slot pinned for a signer a condition of signing: the signing page puts the name and the date on their slots by itself, shows each empty slot, and refuses to record the signature until the signature and stamp slots are used too. It is stored only beside a locked template that pins at least one slot (otherwise the response reports false), and it never applies to a signer the template pins nothing for.

Verify what was applied on the create response (template_id, template_enforcement) or in full via GET /contracts/{code} → template_positions.

Every contract response also carries facts (what you declared, or null) and via: null, or {client_name, kind} when the contract was sent through an AI-assistant connection (MCP). via cannot be set from the request body or a header.

Discount code — discount_code

Send the same code you would type in the panel. It is stored on the contract and applied when the signers are added — by this call (one-shot) or by a later POST /contracts/{code}/signers, which takes no discount parameter of its own. It works in every payer_mode: with creator it lowers what your wallet is charged; with signer / designated it lowers the total the payers split. The contract responses echo it as discount_code.

What the code does NOT promise — the same rules as the panel:

GET /cost-estimate?signers=N&contract={code} returns the amount that will actually be charged.

Send a stuck digital contract again as electronic — replaces

When a signer of your waiting digital contract cannot get a certificate, send replaces with that contract's code and nothing else (optionally signature_method=electronic). The waiting contract ends — canceled if nobody signed, voided with its signed pages kept if only your side signed (or a counterparty signed while «withdraw after signature» is enabled) — and a NEW electronic contract is created with the same document, the same signers in the same order and the same signature boxes; the signing SMS goes again at each signer's turn. The old contract's signature_method never changes. This is exactly the panel's «ارسالِ دوباره با امضای الکترونیک»: the same rule, the same price, one implementation.

The answer is 202 with the new contract (its replaces is the old code) and meta.charged — what this call deducted from the wallet, in toman (0 when the payment carried — and 0 when the half was taken from your package quota instead) — and meta.refunds_due: the total of refunds the resend left due (a certificate pre-payment back to you, AND a certificate fee back to the signer's own wallet who paid it), paid as soon as no enrolment can use them.

Scope: contracts:write.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/contracts" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "title=قرارداد بیمه شخص ثالث"\
    --form "replaces=ABC1234567XYZ890"\
    --form "discount_code=WELCOME10"\
    --form "signature_method=architecto"\
    --form "all_pages_signature="\
    --form "signer_mode=multi"\
    --form "wet_signature_page=0"\
    --form "send_at=2026-11-20T06:30:00Z"\
    --form "is_private="\
    --form "legal_entity_id=16"\
    --form "organisation_sender="\
    --form "trade_name_id=7"\
    --form "template_id=26"\
    --form "template_enforcement=locked"\
    --form "require_all_placements="\
    --form "redirect_url=https://partner.example/contracts/42/signed"\
    --form "signers[]=architecto"\
    --form "payer_mode=signer"\
    --form "signing_deadline_at=2026-11-05T14:30:00Z"\
    --form "facts[counterparty_name]=شرکت آلفا"\
    --form "facts[end_date]=1406/07/29"\
    --form "facts[end_reminder_days]=30"\
    --form "on_company_warning=refuse"\
    --form "file=@C:\Users\pc\AppData\Local\Temp\php878C.tmp" 
const url = new URL(
    "https://elemza.com/api/v1/contracts"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('title', 'قرارداد بیمه شخص ثالث');
body.append('replaces', 'ABC1234567XYZ890');
body.append('discount_code', 'WELCOME10');
body.append('signature_method', 'architecto');
body.append('all_pages_signature', '');
body.append('signer_mode', 'multi');
body.append('wet_signature_page', '0');
body.append('send_at', '2026-11-20T06:30:00Z');
body.append('is_private', '');
body.append('legal_entity_id', '16');
body.append('organisation_sender', '');
body.append('trade_name_id', '7');
body.append('template_id', '26');
body.append('template_enforcement', 'locked');
body.append('require_all_placements', '');
body.append('redirect_url', 'https://partner.example/contracts/42/signed');
body.append('signers[]', 'architecto');
body.append('payer_mode', 'signer');
body.append('signing_deadline_at', '2026-11-05T14:30:00Z');
body.append('facts[counterparty_name]', 'شرکت آلفا');
body.append('facts[end_date]', '1406/07/29');
body.append('facts[end_reminder_days]', '30');
body.append('on_company_warning', 'refuse');
body.append('file', document.querySelector('input[name="file"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());

Example response (402, one-shot send with signers, wallet cannot cover the fee — nothing is created; retrying will not help until the wallet is topped up):


{
    "type": "https://docs.elemza.com/errors/insufficient_balance",
    "status": 402,
    "code": "insufficient_balance",
    "title_fa": "موجودی کیف پول کافی نیست",
    "title_en": "Insufficient wallet balance",
    "meta": {
        "balance_toman": 29750,
        "required_toman": 60500,
        "shortfall_toman": 30750
    }
}
 

Example response (403, replaces: refused for a reason that can change (the switch, your verification or company, the withdraw rule) — nothing ended or charged; not stored under the Idempotency-Key):


{
    "type": "https://docs.elemza.com/errors/replace_not_available",
    "status": 403,
    "code": "replace_not_available",
    "title_fa": "ارسالِ دوباره با امضای الکترونیک فعلاً فعال نیست.",
    "title_en": "This contract cannot be sent again as electronic right now; fix the cause and send the same request again"
}
 

Example response (409, replaces: this contract can never be resent (e.g. signers pay, already ended) — nothing ended or charged):


{
    "type": "https://docs.elemza.com/errors/replace_not_allowed",
    "status": 409,
    "code": "replace_not_allowed",
    "title_fa": "این قرارداد منتظرِ امضا نیست.",
    "title_en": "This contract cannot be sent again as electronic in its current state"
}
 

Example response (409, replaces: another resend of the same contract is running — retry shortly):


{
    "type": "https://docs.elemza.com/errors/replace_busy",
    "status": 409,
    "code": "replace_busy",
    "title_fa": "همین قرارداد همین حالا در حالِ ارسالِ دوباره است؛ چند ثانیهٔ دیگر دوباره امتحان کنید.",
    "title_en": "This contract is being sent again by another request; retry shortly"
}
 

Example response (409, replaces: a signature landed (or the price changed) while it was being sent — nothing ended or charged; not stored under the Idempotency-Key, send the same request again):


{
    "type": "https://docs.elemza.com/errors/replace_state_changed",
    "status": 409,
    "code": "replace_state_changed",
    "title_fa": "هزینهٔ نسخهٔ تازه از وقتی این پنجره باز شد عوض شده است؛ دوباره باز کنید و ببینید.",
    "title_en": "The contract changed while it was being sent again; nothing changed — send the same request again"
}
 

Example response (422, template_id not reachable by the caller):


{
    "type": "https://docs.elemza.com/errors/template_not_accessible",
    "status": 422,
    "code": "template_not_accessible",
    "title_fa": "قالب انتخاب‌شده وجود ندارد یا در دسترس شما نیست",
    "title_en": "The selected template does not exist or is not accessible to you",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS"
}
 

Example response (422, discount_code is unknown, inactive, expired, used up or not issued to this account — nothing is created):


{
    "type": "https://docs.elemza.com/errors/discount_code_invalid",
    "status": 422,
    "code": "discount_code_invalid",
    "title_fa": "کد تخفیف معتبر نیست یا برای این حساب قابل استفاده نیست؛ آن را اصلاح کنید یا نفرستید",
    "title_en": "The discount code is not valid for this account; correct it or omit discount_code",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS",
    "errors": [
        {
            "field": "discount_code",
            "code": "invalid",
            "title_fa": "کد تخفیف معتبر نیست",
            "title_en": "Invalid discount code"
        }
    ]
}
 

Example response (422, replaces sent with another field — nothing is ended or created):


{
    "type": "https://docs.elemza.com/errors/replaces_conflict",
    "status": 422,
    "code": "replaces_conflict",
    "title_fa": "با «replaces» همان سند و همان امضاکنندگان دوباره فرستاده می‌شوند؛ فیلدِ دیگری نفرستید",
    "title_en": "With replaces the same document and signers are sent again; send no other field",
    "errors": [
        {
            "field": "title",
            "code": "not_allowed_with_replaces",
            "title_fa": "این فیلد کنارِ replaces پذیرفته نمی‌شود",
            "title_en": "Not allowed with replaces"
        }
    ]
}
 

Request      

POST api/v1/contracts

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: multipart/form-data

Accept        

Example: application/json

Body Parameters

title   string     

Contract title (1..255 chars — the same limit as the panel). Example: قرارداد بیمه شخص ثالث

replaces   string  optional    

Optional — the 16-character code of YOUR waiting DIGITAL contract to send again as electronic (see «Send a stuck digital contract again as electronic» above). Sent alone: then title is not required and every other field is refused (422 replaces_conflict). Example: ABC1234567XYZ890

discount_code   string  optional    

Optional discount code (max 32 chars, case-insensitive). A code that is unknown, inactive, expired, used up or not issued to your account is rejected with 422 discount_code_invalid and nothing is created — it is never silently dropped. Validity is checked now and the amount is computed when signers are added; nothing is reserved in between (see «Discount code» above for when a stored code gives no discount). A contract's code cannot be changed after creation. Example: WELCOME10

signature_method   string  optional    

electronic|digital. Default electronic. digital = PADES signature via the Pendar CA cloud-HSM. Requires the PKI feature to be enabled for your account (pre-flight via GET /me → data.capabilities.pki), otherwise 403 pki_not_available. The method is contract-wide (all signers sign the same way) and IMMUTABLE after creation — to change it, cancel and recreate (ADR-0009). Example: architecto

all_pages_signature   boolean  optional    

Default false. When true, every page must carry the signature element. Refused (422) together with signer_mode=multi. Example: false

signer_mode   string  optional    

Only with signature_method=digital: solo (exactly one signer — electronic-style placement, then one invisible digital seal) or multi (two or more signers, each adding one signature in turn). Omit it and a digital contract behaves exactly as before — nothing below is checked. When sent: with electronic it is 422; the signer count must fit (inline signers at creation, and the POST /contracts/{code}/signers batch later — 422 signer_mode_mismatch, nothing added or charged); with multi the template must suit a multi-signer digital contract (signers 2+ pin at most one «signature» each, no stamp/name/date, no «all signers» box — 422 template_not_digital_compatible) and all_pages_signature must not be true. Example: multi

wet_signature_page   integer  optional    

0 = no visible signature mark: the signed PDF carries only the digital signature, and each signer only confirms they read the document. Only with signature_method=digital and signer_mode=multi (where the panel offers it); anywhere else 422. -1 (or omitting it) keeps the default — each signer places a visible signature. Example: 0

send_at   string  optional    

Optional scheduled send: ISO-8601 date-time WITH an explicit offset (Z or +03:30), strictly in the future and at most 3 months ahead (the panel's window); outside it is 422 and nothing is created. The signers are added — and the send is charged — when they are added (inline or by POST /contracts/{code}/signers); only the signing SMS waits until this moment. Signers added after it has passed get their SMS at once. With send_at, the bounds of signing_deadline_at are measured from send_at, not from now. Example: 2026-11-20T06:30:00Z

is_private   boolean  optional    

Default false. When true, hides contract from org-ancestors. Example: false

legal_entity_id   integer  optional    

Optional — send this contract on behalf of one of your registered companies. The signer's SMS, the signing page and the signed PDF then carry that company's name instead of yours. List the ids you may use via GET /api/v1/me (data.legal_entities).

       **Account default.** If you set a default company in the panel
       («شرکت‌های من» → «پیش‌فرضِ من باشد»), OMITTING this field sends the contract on
       behalf of that company — so an integration that always signs as the company needs
       no code change at all. `GET /api/v1/me` reports it as
       `data.default_legal_entity_id`, so you can always tell which name a contract will
       go out under BEFORE you create it. With no default set, omitting the field sends
       under your own name, exactly as before.

       **To send one contract personally while a default is set, pass `0`** (or `null`).
       An absent field means «use my default»; an explicit `0` means «me, personally».
       These are deliberately different — a caller that cannot say «personally» would
       have no way back out of the default. Example: `16`
organisation_sender   boolean  optional    

Optional — true sends this one contract under the name of the ORGANISATION you are a member of (its verified company), even when your account has a default company. Only for a member the organisation lends its name to (a full manager, or a member set to «به‌نامِ سازمان»), and only while the organisation has a verified company; otherwise 422 organisation_not_available and nothing is created. It cannot be sent together with legal_entity_id or trade_name_id, whatever their value (422 sender_conflict). Absent or false: nothing changes. Example: false

trade_name_id   integer  optional    

Optional — send this contract under one of your TRADE NAMES (نامِ تجاری, e.g. a shop name from your guild licence); the signer reads «فروشگاه مهر (علی رضایی)» in the SMS, e-mail and signing page. You remain the party of the contract, the signer and the invoice buyer. List the ids via GET /api/v1/me → data.trade_names (can_use). A trade name is never chosen by omitting this field; 0 means «me, personally» (and overrides an account default company). Another user's id → 422 trade_name_not_accessible; yours but not usable now (licence ended, identity to be re-verified) → 422 trade_name_not_usable; together with legal_entity_id > 0 → 422 sender_conflict. The response carries data.sender {name, as, trade_name, legal_entity_id}. legal_entity_id: 0 now means «personally» for organisation members too (it used to let an organisation's company speak for an Admin member who asked to be personal).

       A company you do not actively represent is rejected with 422
       `legal_entity_not_accessible`; one whose registered board term has expired with
       422 `legal_entity_board_expired`. If your account default has itself become
       unusable (representation revoked, company archived), creation fails with 422
       `default_legal_entity_unusable` rather than silently reverting to your personal
       name. Example: `7`
template_id   integer  optional    

Optional — must be owned by the caller or shared from the org root; anything else is rejected with 422 template_not_accessible (never silently dropped). List valid ids via GET /api/v1/templates. Example: 26

template_enforcement   string  optional    

locked|suggested (legacy aliases: strict|loose). Defaults to locked when template_id is set. Example: locked

require_all_placements   boolean  optional    

Default false. With a locked template: the signer must use every slot the template pins for them (signature, stamp, name, date) before the signature is recorded. Ignored without a locked template that pins a slot. Example: false

redirect_url   string  optional    

HTTPS URL to send the signer back to after they finish signing. They see our confirmation first, then return automatically. Without it they stay on our confirmation page. Example: https://partner.example/contracts/42/signed

file   file  optional    

PDF or PNG/JPG, max 4MB (multipart/form-data only). Example: C:\Users\pc\AppData\Local\Temp\php878C.tmp

source   object  optional    

Optional document source instead of file (JSON body). One of:

       `{type: "form_submission", code: "ABCD1234EFGH5678"}` — uses the rendered PDF of one
       of YOUR form submissions as this contract's document (the فرم → PDF → امضا chain,
       works with both signature methods). 409 `not_ready` if the submission PDF is still
       rendering; 422 `not_applicable` for online-renderer forms (no PDF artifact).

       `{type: "url", url: "https://…"}` — we download the document from that link once, before
       anything is created: HTTPS on port 443 only, no redirects, at most 4 MB, and it must be a
       PDF, PNG or JPEG by its content. A link that points at a private or internal address (or
       whose name resolves to one) is refused. Every refusal is 422 `source_url_refused` with
       `meta.reason` (`not_https`, `credentials_in_url`, `port_not_allowed`, `internal_hostname`,
       `dns_unresolvable`, `private_address`, `redirect`, `http_status`, `too_large`,
       `unsupported_type`, `empty`, `timeout`, `connect_failed`, `tls_error`, `fetch_failed`).
       The link itself is not stored and its query string is never logged.

       `{type: "upload", id: "01J…"}` — a file the account owner put on an elEMZA upload page
       started by an AI-assistant connection. Usable once, by that owner, while it has not
       expired; anything else is 422 `upload_not_usable` with `meta.reason` (`not_found`,
       `not_ready`, `expired`, `consumed`, `files_invalid`). The upload belongs to the mode of
       the connection that started it: a test-mode upload with a live token (or the reverse)
       is 409 `upload_mode_mismatch`, and the upload is not consumed.

       Whatever the source, the created contract records the SHA-256 of the document's bytes
       (for several files, of their digests joined by newlines in order).
signers   string[]  optional    

Optional inline signers (one-shot). Same shape as POST /contracts/{code}/signers.

is_payer   boolean  optional    

Only with payer_mode=designated: this signer pays a share of the signature fee. Example: true

template_slot   integer  optional    

Which signature box of the template is this signer's: 1..the template's highest box, each box to one signer, or 0 for free placement (may repeat). Only with a template_id whose template has at least two boxes; otherwise, for a box the template does not have, or for a box given twice, 422 and nothing is created. Signers without it get the lowest free box. Omit it on every signer and boxes follow the signers' order, exactly as before. Example: 2

signature_sheet_labels   string[]  optional    

Optional — «امضا روی برگِ پایانی»: instead of boxes on the document, ONE A4 page is appended to it with one labelled box per signature, and every signature lands in its own box on that page. 1 to 8 labels; each is printed above its box as given (at most 60 characters after trimming, no control characters), and an empty string prints «امضاکنندهٔ ۱», «امضاکنندهٔ ۲» …. Box i belongs to the signer whose template_slot is i — every signer, inline or added later with POST /contracts/{code}/signers, must send one, and every box needs its own signer: send exactly as many signers as labels, each person once (fewer, or one mobile twice, is 422 — a box nobody holds would stay empty on the completed document). The page is part of the document people sign (it is counted in page_count and in the document digest); GET /contracts/{code} returns its page as signature_sheet_page once the document is processed. The boxes are locked: each signature is accepted only in its box. Refused (422, nothing created) together with template_id, all_pages_signature=true, wet_signature_page=0 or template_enforcement=suggested. The page is always A4 portrait, so a landscape or non-A4 document ends on a page of another size; more than 8 signatures cannot use it. Example: ["امضای فروشنده","امضای خریدار"]

payer_mode   string  optional    

Who pays the signature fee. creator (default) — your wallet pays the whole fee when signers are added, exactly as before. signer — the fee is split equally between ALL signers and each pays their share on the signing page before signing. designated — split only between the signers you flag with is_payer: true; everyone else signs for free.

       In `signer` and `designated` your wallet is charged a **commitment** of half of each payer's
       share when signers are added. It comes back to you when that signer pays. If a payer neither
       pays nor signs within the settlement window, the contract is cancelled and that half is kept.
       Check availability first via `GET /me` → `data.capabilities.signer_pays`
       (and `signer_pays_window_days`).

       A sharing mode that is not available is rejected with 422 `payer_mode_unavailable` — it is
       never silently switched to `creator`. `designated` with signers but no `is_payer` is 422
       `payer_required`; `is_payer` in any other mode is 422 `payer_not_applicable`. Test (sandbox)
       tokens record the mode but move no money and ask no signer to pay. Example: `signer`
signing_deadline_at   string  optional    

Optional ISO-8601 date-time WITH an explicit offset (Z or +03:30) after which nobody new may sign — a zone-less or relative value («tomorrow») is 422. At least one hour and at most 180 days from now (the life of the signing link); outside that range is 422 validation and nothing is created. Omit it for no deadline (the default — exactly as before). When it passes: a contract nobody has signed is cancelled (contract.canceled with reason: signing_deadline, refund by the usual cancel rule); a contract someone has signed stays waiting_signature but accepts no further signature until the owner extends the deadline in the panel. Either way contract.signing_deadline.passed fires with outcome canceled or closed. With payer_mode signer/designated the payment window never ends later than this. In the two-step flow the deadline is re-checked when the document or the signers arrive: passed or less than an hour away ⇒ 422 signing_deadline_passed. Returned as signing_deadline_at (and signing_closed_at once signing was closed). Example: 2026-11-05T14:30:00Z

facts   object  optional    

Optional facts you DECLARE about the contract, so you can later list «which contracts end next quarter» (GET /contracts?ends_before=…). Keys, all optional: counterparty_name (≤ 190), contract_type (≤ 64), start_date, end_date (Jalali 1405/08/01 or ISO 2026-10-23; the end not before the start), amount_toman (integer ≥ 0), auto_renew (boolean), notes (≤ 1000), end_reminder_days (7, 30 or 60 — we remind you that many days before end_date, and with 30 or 60 again 7 days before; needs an end_date). An unknown key or an unreadable date is 422 and nothing is created. They are returned on every contract response as facts (dates in both calendars, declared: true, source), and can be corrected later with PATCH /contracts/{code}/facts. Apart from that reminder, nothing automatic acts on them.

on_company_warning   string  optional    

With inline company signers: continue (default — sent, and the 202 carries meta.company_checks) or refuse (409 company_check_warning on a high warning; nothing is created). Example: refuse

Upload contract file(s) (two-step flow)

requires authentication

Attaches a file to an existing draft contract that has no pages yet. Same async pipeline as POST /contracts one-shot: stages bytes, dispatches ProcessContractFilesJob, returns 202 with the processing link.

A contract has exactly one document. Once one is attached — by POST /contracts with a file/source, or by an earlier call here, even while it is still processing — another upload is 409 document_already_attached and the recorded document is unchanged. To use a different document, cancel the contract and create a new one. Use the same kind of token (live/test) that created the contract, else 409 sandbox_mode_mismatch.

The one exception: a document that could not be processed (GET /contracts/{code}/processing answers step=error and the contract has no pages) is no document. Upload the corrected file here; it replaces the failed one. Signers sent inline with the failed one-shot request were never added — add them with POST /contracts/{code}/signers once the new document is ready.

An electronic replacement (replaces set) takes no file here, in any state — its document is the replaced contract's: 409 replacement_document_fixed. If it failed for good, the answer says so; cancel it or contact support.

After the 202, wait for GET /contracts/{code}/processing to answer ready=true (or for the contract.processing.completed webhook) before adding signers: the signing SMS does not wait for the pages.

A contract created with signing_deadline_at is re-checked here against the CURRENT time: if the deadline has passed or is less than an hour away the upload is 422 signing_deadline_passed and nothing is staged.

Scope: contracts:write.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/contracts/architecto/files" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "file=@C:\Users\pc\AppData\Local\Temp\php879D.tmp" 
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/files"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('file', document.querySelector('input[name="file"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());

Example response (409, the contract already has its document (attached at creation or by an earlier upload)):


{
    "type": "https://docs.elemza.com/errors/document_already_attached",
    "status": 409,
    "code": "document_already_attached",
    "title_fa": "این قرارداد قبلاً سند دارد و سندش جایگزین نمی‌شود؛ برای سندِ دیگر، این قرارداد را لغو و قراردادِ تازه بسازید",
    "title_en": "This contract already has its document and it cannot be replaced; cancel it and create a new contract for another document"
}
 

Example response (409, an electronic replacement (`replaces` set): its document is the replaced contract's and is prepared by the system — no file is accepted, in any state):


{
    "type": "https://docs.elemza.com/errors/replacement_document_fixed",
    "status": 409,
    "code": "replacement_document_fixed",
    "title_fa": "سندِ این نسخهٔ الکترونیک همان سندِ قراردادِ قبلی است و سامانه خودش آن را آماده می‌کند؛ فایلِ دیگری پذیرفته نمی‌شود.",
    "title_en": "This electronic replacement's document is the replaced contract's and is prepared by the system; another file is not accepted."
}
 

Example response (409, an electronic replacement whose document could not be prepared — waiting will not help; cancel it or contact support):


{
    "type": "https://docs.elemza.com/errors/replacement_document_fixed",
    "status": 409,
    "code": "replacement_document_fixed",
    "title_fa": "سندِ این نسخهٔ الکترونیک آماده نشد و امضاکنندگانش منتقل نمی‌شوند؛ صبرکردن کمکی نمی‌کند. این قرارداد را لغو کنید یا با پشتیبانی تماس بگیرید.",
    "title_en": "This electronic replacement's document could not be prepared; another file is not accepted. Cancel it or contact support."
}
 

Request      

POST api/v1/contracts/{code}/files

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: multipart/form-data

Accept        

Example: application/json

URL Parameters

code   string     

16-char contract code. Example: architecto

Body Parameters

file   file     

PDF or PNG/JPG, max 4MB (multipart/form-data). Example: C:\Users\pc\AppData\Local\Temp\php879D.tmp

Cancel contract

requires authentication

Cancels a contract in draft or waiting_signature state. Refunds the billed amount to the original wallet (100% if no signer signed, 50% if any Shahkar was consumed). Deletes contract files from storage. Waiting signers receive an SMS notifying them the contract was canceled.

Use the same kind of token (live/test) that created the contract: a test token on a live contract, or a live token on a test one, is 409 sandbox_mode_mismatch and nothing is cancelled, deleted, refunded or sent.

Scope: contracts:write.

Example request:
curl --request DELETE \
    "https://elemza.com/api/v1/contracts/architecto" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());

Example response (200):


{
    "data": {
        "code": "ABC1234567XYZ890",
        "status": "canceled",
        "canceled_at": "2026-05-11T10:00:00.000Z",
        "refund": {
            "amount": 60000,
            "currency": "IRT"
        },
        "end_reason": "manual"
    }
}
 

Example response (409, token of the other mode (test token, live contract — or the reverse); nothing changed):


{
    "type": "https://docs.elemza.com/errors/sandbox_mode_mismatch",
    "status": 409,
    "code": "sandbox_mode_mismatch",
    "title_fa": "این قرارداد با توکنِ زنده ساخته شده؛ آن را با همان نوع توکن لغو کنید",
    "title_en": "This contract was created with a live token; cancel it with the same kind of token"
}
 

Request      

DELETE api/v1/contracts/{code}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char public code. Example: architecto

Withdraw contract

requires authentication

Takes a contract back after at least one signer has signed and before the last one has — the sender changed his mind, or found a mistake the signers must not sign. Until everyone has signed nothing is binding, so no one else's consent is needed. Use DELETE /contracts/{code} instead while nobody has signed.

The contract becomes voided with end_reason withdrawn_by_sender. The signed pages are KEPT (they are evidence), the refund and the package quota follow the same rule as a cancel, waiting signers receive the cancellation SMS, and signers who already signed are told. Your reason is stored for your own records and the audit trail; it is not sent to the signers or in the webhook. The contract.voided webhook fires — the specific event — and contract.canceled fires too, with reason withdrawn_by_sender, so an integration that only knows contract.canceled still learns the contract ended. Handle contract.voided and ignore a contract.canceled whose reason is withdrawn_by_sender if you subscribe to both.

Only the account that created the contract may withdraw it. The feature is switched off until it is enabled for the platform; while off, every call is 403 withdraw_not_available. With a test token on a test contract nothing is charged, refunded or texted.

Scope: contracts:write.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/contracts/architecto/withdraw" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"reason\": \"مبلغِ بندِ دوم اشتباه نوشته شده بود.\"
}"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/withdraw"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "reason": "مبلغِ بندِ دوم اشتباه نوشته شده بود."
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "data": {
        "code": "ABC1234567XYZ890",
        "status": "voided",
        "voided_at": "2026-10-29T10:00:00.000Z",
        "refund": {
            "amount": 30000,
            "currency": "IRT",
            "reason": "contract_withdrawn"
        },
        "end_reason": "withdrawn_by_sender"
    }
}
 

Example response (403, not the contract's creator):


{
    "type": "https://docs.elemza.com/errors/policy_denied",
    "status": 403,
    "code": "policy_denied",
    "title_fa": "فقط فرستندهٔ قرارداد می‌تواند آن را پس بگیرد.",
    "title_en": "Only the contract's creator can withdraw it"
}
 

Example response (409, nobody has signed yet, everyone has signed, or the contract has ended):


{
    "type": "https://docs.elemza.com/errors/not_withdrawable",
    "status": 409,
    "code": "not_withdrawable",
    "title_fa": "همهٔ امضاکنندگان امضا کرده‌اند؛ این قرارداد دیگر پس‌گرفتنی نیست.",
    "title_en": "The contract cannot be withdrawn in its current state"
}
 

Request      

POST api/v1/contracts/{code}/withdraw

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char public code. Example: architecto

Body Parameters

reason   string     

Why you are taking it back, 10–500 characters. Example: مبلغِ بندِ دوم اشتباه نوشته شده بود.

Declare or correct a contract's facts

requires authentication

Merges into what is already declared: a key you leave out is unchanged, a key sent as null is cleared. Only the contract's creator may declare — a signer can read the facts on GET /contracts/{code}, not change them. Every change clears confirmed_at (a confirmation was of the old values). When every field ends up empty the facts are removed and data is null.

Send confirm: true to mark the declared facts as confirmed — e.g. once the contract has gone out with them. Alone it changes no field (and not source); with changes in the same body it confirms the new values. Confirming again keeps the first confirmed_at. With nothing declared there is nothing to confirm: data is null. Any value other than true is 422.

Dates: Jalali 1405/08/01 (Persian digits accepted) or ISO 2026-10-23; stored as the Gregorian day and returned in both calendars. A Jalali year written with dashes (1405-08-01) is refused, never shifted six centuries.

Scope: contracts:write. Send an Idempotency-Key to make a retry safe.

Example request:
curl --request PATCH \
    "https://elemza.com/api/v1/contracts/ABC1234567XYZ890/facts" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"counterparty_name\": \"شرکت آلفا\",
    \"contract_type\": \"اجاره\",
    \"start_date\": \"1405\\/08\\/01\",
    \"end_date\": \"1406\\/07\\/30\",
    \"amount_toman\": 120000000,
    \"auto_renew\": false,
    \"notes\": \"تمدید با توافق کتبی\",
    \"end_reminder_days\": 30,
    \"confirm\": true
}"
const url = new URL(
    "https://elemza.com/api/v1/contracts/ABC1234567XYZ890/facts"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "counterparty_name": "شرکت آلفا",
    "contract_type": "اجاره",
    "start_date": "1405\/08\/01",
    "end_date": "1406\/07\/30",
    "amount_toman": 120000000,
    "auto_renew": false,
    "notes": "تمدید با توافق کتبی",
    "end_reminder_days": 30,
    "confirm": true
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "data": {
        "counterparty_name": "شرکت آلفا",
        "contract_type": "اجاره",
        "start_date": "2026-10-23",
        "start_date_jalali": "1405/08/01",
        "end_date": "2027-10-21",
        "end_date_jalali": "1406/07/29",
        "amount_toman": 120000000,
        "auto_renew": false,
        "notes": null,
        "source": "api",
        "confirmed": false,
        "confirmed_at": null,
        "confirmed_at_jalali": null,
        "declared": true
    }
}
 

Example response (403, you can see it (e.g. as a signer) but did not create it):


{
    "type": "https://docs.elemza.com/errors/policy_denied",
    "status": 403,
    "code": "policy_denied",
    "title_fa": "فقط سازندهٔ قرارداد می‌تواند اطلاعاتِ آن را اعلام کند",
    "title_en": "Only the contract's creator can declare its facts"
}
 

Example response (404, unknown code, or a contract you cannot see):


{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "قرارداد یافت نشد",
    "title_en": "Contract not found"
}
 

Request      

PATCH api/v1/contracts/{code}/facts

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char public code. Example: ABC1234567XYZ890

Body Parameters

counterparty_name   string  optional    

The other party, as written on the document (≤ 190). Example: شرکت آلفا

contract_type   string  optional    

What kind of contract it is (≤ 64), e.g. «اجاره», «خدمات». Example: اجاره

start_date   string  optional    

First day of the term — Jalali 1405/08/01 or ISO 2026-10-23. Example: 1405/08/01

end_date   string  optional    

Last day of the term; not before start_date. Same formats. Example: 1406/07/30

amount_toman   integer  optional    

The contract amount in Toman, ≥ 0. Example: 120000000

auto_renew   boolean  optional    

Whether the contract renews by itself. Example: false

notes   string  optional    

Free text, ≤ 1000 characters. Example: تمدید با توافق کتبی

end_reminder_days   integer  optional    

Remind the contract's sender this many days before end_date — 7, 30 or 60, or null for no reminder. Needs an end_date that has not passed. With 30 or 60 a second reminder follows 7 days before. Example: 30

confirm   boolean  optional    

Only true: mark the declared facts as confirmed (confirmed, confirmed_at). Example: true

Digital certificates (PKI)

Issuing a certificate is not something an API can do on somebody's behalf: the law wants an OTP that person typed and a live face check they attended. So these endpoints do the part an API legitimately can — start the enrolment, hand back a link for the person, and let the integrator follow it to the end.

Certificate status for one of your people

requires authentication

Answers "can this person sign digitally yet?" for somebody you have enrolled.

Privacy — this is not a lookup service for arbitrary national codes. It only answers for people you yourself started an enrolment for; anyone else returns 404, so the endpoint cannot be used to discover whether a given Iranian holds a certificate.

Scope required: certificates:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/certificates?national_code=0010350829" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/certificates"
);

const params = {
    "national_code": "0010350829",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200, Active certificate):


{
    "data": {
        "national_code": "0010350829",
        "status": "active",
        "valid_from": "2026-07-30T09:12:00.000Z",
        "valid_until": "2027-07-30T09:12:00.000Z",
        "mode": "live"
    }
}
 

Example response (200, Enrolment still in progress):


{
    "data": {
        "national_code": "0010350829",
        "status": "pending_ekyc",
        "valid_from": null,
        "valid_until": null,
        "mode": "live"
    }
}
 

Request      

GET api/v1/certificates

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

national_code   string     

The person's national code. Example: 0010350829

One enrolment request

requires authentication

The state of a single enrolment you started, by the request_id you received.

Scope required: certificates:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/certificates/01jqk8x2m4n6p8r0s2t4v6w8y0" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/certificates/01jqk8x2m4n6p8r0s2t4v6w8y0"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG9758NSZWEFCPQ3SPB8K
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG9758NSZWEFCPQ3SPB8K"
}
 

Request      

GET api/v1/certificates/{id}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   string     

The request_id from the onboarding call. Example: 01jqk8x2m4n6p8r0s2t4v6w8y0

Start a certificate enrolment

requires authentication

Creates a short-lived, single-use link for one of your users to obtain a digital certificate. Send them to onboarding_url; they complete the SMS code, the identity form and the video check on our pages, and you learn the outcome from certificate.issued / certificate.failed (or by polling GET /api/v1/certificates/{request_id}).

Who pays — pay_by: "issuer" charges YOUR wallet for the one-time issuance fee right now and refunds it automatically if no certificate is ever issued. pay_by: "subject" (default) lets the person pay on the page.

Idempotency — while an enrolment for the same national code is still open you get the SAME link back, not a second one. Pendar treats an open enrolment as a single order.

Scope required: certificates:write.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/certificates/onboarding" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"national_code\": \"0010350829\",
    \"mobile\": \"09121234567\",
    \"first_name\": \"علی\",
    \"last_name\": \"رضایی\",
    \"pay_by\": \"issuer\",
    \"redirect_url\": \"https:\\/\\/partner.example\\/done\",
    \"ttl_minutes\": 120
}"
const url = new URL(
    "https://elemza.com/api/v1/certificates/onboarding"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "national_code": "0010350829",
    "mobile": "09121234567",
    "first_name": "علی",
    "last_name": "رضایی",
    "pay_by": "issuer",
    "redirect_url": "https:\/\/partner.example\/done",
    "ttl_minutes": 120
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (201, Link created):


{
    "data": {
        "request_id": "01jqk8x2m4n6p8r0s2t4v6w8y0",
        "onboarding_url": "https://elemza.com/pki/onboarding/01jqk8x2m4n6p8r0s2t4v6w8y0?expires=...&signature=...",
        "expires_at": "2026-07-30T12:00:00.000Z",
        "status": "pending",
        "pay_by": "issuer",
        "mode": "live"
    }
}
 

Request      

POST api/v1/certificates/onboarding

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

national_code   string     

The person's 10-digit national code. Example: 0010350829

mobile   string     

Their mobile, 09xxxxxxxxx. Example: 09121234567

first_name   string  optional    

Optional, prefills the form. Example: علی

last_name   string  optional    

Optional, prefills the form. Example: رضایی

pay_by   string  optional    

issuer or subject (default). Example: issuer

redirect_url   string  optional    

HTTPS URL to send the person back to when they finish. Example: https://partner.example/done

ttl_minutes   integer  optional    

Link lifetime, 5–1440 (default 60). Example: 120

Endpoints

Invoke the controller method.

requires authentication

Example request:
curl --request GET \
    --get "https://elemza.com/api/documentation" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/documentation"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (500):

Show headers
x-request-id: 01M7RWG9DWE7WEE3KA8MTMPXY1
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
x-ratelimit-limit: 30
x-ratelimit-remaining: 29
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
set-cookie: XSRF-TOKEN=eyJpdiI6ImoxL1phaWMwZUdRK0RQQWxzUm1aL2c9PSIsInZhbHVlIjoiR083RGtUMHRKOXpqZHhwbGVpek5NL01aZXBMVG5xZ1FkYTc1aUN5ZWFHb1Zud1BHZXdZR1dHVE9kcmk3Smg0aEVNak8rQnV1MHJ2eDJtSG92T3RidHA0aG9ZaDdOVk4vZ3A3QXhTaXc1eUh0aHZiR1QzSUhzeXM4d2htcHhQTzMiLCJtYWMiOiI1NzgxNjRiNzY0YTQwYjc2MGQwNDZlM2ViM2I2MzhlNmU3MzcyYzFhYzI1OGI0YTNlOGYxM2E2NGM1NjFiOGEyIiwidGFnIjoiIn0%3D; expires=Thu, 19 Nov 2026 05:09:48 GMT; Max-Age=7200; path=/; samesite=lax; emza_session=eyJpdiI6IkVuWFllc1RudFBwWEI2YnZxMFVMUEE9PSIsInZhbHVlIjoiV3dSMkQ2L2U4Um8wOHp3YnphOURwbXVlVHFvNVlUWVQ2VDhoc1hyL3FWV096Q3FjeDJOc05zeFdpcUxBR3Y0emFZY0g4bEtLM1R6bDFDQ0o0RTlndzJYbEozSGkvVFFKVHM0Y1V5bnNoS0ozOUR1WHoyNGk3SnFjNnBhNHkxMmMiLCJtYWMiOiI1YWUyYjVjNTI0ZWIzZmU5YmVhMTcyOTBhZjAxOGEwMThlNGEwNzEyMWJmYmNmYzlhMmYxMmQ0ZmVjZGZiZDdiIiwidGFnIjoiIn0%3D; expires=Thu, 19 Nov 2026 05:09:48 GMT; Max-Age=7200; path=/; httponly; samesite=lax
 

{
    "type": "https://docs.elemza.com/errors/internal_error",
    "status": 500,
    "code": "internal_error",
    "title_fa": "خطای داخلی سرور",
    "title_en": "Internal server error",
    "request_id": "01M7RWG9DWE7WEE3KA8MTMPXY1"
}
 

Request      

GET api/documentation

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Form submissions — fill a form through the API (ADR-0029)

Submit-once semantics: no draft/resume, no edit-after-submit (FB SCOPE-CONTRACT rows 6/7). Ownership: every endpoint requires the form to BELONG to the token owner (v2 schema only) — the integrator drives fills of their OWN forms; end users never hold tokens.

Public signed-URL download twin (no Bearer — the URL signature is the auth proof, minted by downloadPdf() after the bearer was verified). Mirrors contracts /dl.

requires authentication

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/form-submissions/architecto/dl" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/form-submissions/architecto/dl"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG8WEN7FG20F0QQ53D2A9
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG8WEN7FG20F0QQ53D2A9"
}
 

Request      

GET api/v1/form-submissions/{code}/dl

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char submission code. Example: architecto

Public signed-URL twin for a single field file (no Bearer — the signature is the auth proof, minted by downloadFieldFile() only after the bearer was verified).

requires authentication

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/form-submissions/architecto/files/architecto/dl" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/form-submissions/architecto/files/architecto/dl"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG8WN0SYK2DV0P3HVRFEV
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG8WN0SYK2DV0P3HVRFEV"
}
 

Request      

GET api/v1/form-submissions/{code}/files/{field}/dl

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char submission code. Example: architecto

field   string     

The field's technical name. Example: architecto

List submissions

requires authentication

Paginated, newest first. Scope: forms:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/forms/architecto/submissions?status=architecto&submitted_after=architecto&submitted_before=architecto&has_contract=&reference=wc%3Ashop.ir%3A1234&per_page=16" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"status\": \"signed\",
    \"submitted_after\": \"2026-11-19T06:39:48\",
    \"submitted_before\": \"2026-11-19T06:39:48\",
    \"has_contract\": false,
    \"reference\": \"b\",
    \"page\": 22,
    \"per_page\": 7
}"
const url = new URL(
    "https://elemza.com/api/v1/forms/architecto/submissions"
);

const params = {
    "status": "architecto",
    "submitted_after": "architecto",
    "submitted_before": "architecto",
    "has_contract": "0",
    "reference": "wc:shop.ir:1234",
    "per_page": "16",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "signed",
    "submitted_after": "2026-11-19T06:39:48",
    "submitted_before": "2026-11-19T06:39:48",
    "has_contract": false,
    "reference": "b",
    "page": 22,
    "per_page": 7
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG94TETS16W58DNC7KJH0
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG94TETS16W58DNC7KJH0"
}
 

Request      

GET api/v1/forms/{slug}/submissions

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

slug   string     

The form's slug. Example: architecto

Query Parameters

status   string  optional    

draft|pending_payment|submitted|processing|completed|signed. Example: architecto

submitted_after   string  optional    

ISO 8601. Example: architecto

submitted_before   string  optional    

ISO 8601. Example: architecto

has_contract   boolean  optional    

Only submissions that bridged to a contract that is still live (true), or that have none — never made, or cancelled/withdrawn (false). Example: false

reference   string  optional    

Only the submission(s) you stored under this reference (exact match). Example: wc:shop.ir:1234

per_page   integer  optional    

Max 100, default 20. Example: 16

Body Parameters

status   string  optional    

Example: signed

Must be one of:
  • draft
  • pending_payment
  • submitted
  • processing
  • completed
  • signed
submitted_after   string  optional    

value یک تاریخ معتبر نیست. Example: 2026-11-19T06:39:48

submitted_before   string  optional    

value یک تاریخ معتبر نیست. Example: 2026-11-19T06:39:48

has_contract   boolean  optional    

Example: false

reference   string  optional    

value نباید بیشتر از 100 کاراکتر باشد. Example: b

page   integer  optional    

value باید حداقل 1 باشد. Example: 22

per_page   integer  optional    

value باید حداقل 1 باشد. value نباید بیشتر از 100 باشد. Example: 7

Get one submission

requires authentication

Scope: forms:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/forms/architecto/submissions/architecto" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/forms/architecto/submissions/architecto"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG95490WW1DTM1VVFS9K4
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG95490WW1DTM1VVFS9K4"
}
 

Request      

GET api/v1/forms/{slug}/submissions/{code}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

slug   string     

The form's slug. Example: architecto

code   string     

16-char submission code. Example: architecto

Download submission PDF

requires authentication

Image-overlay forms render a final PDF per submission (queued at submit). Same signed-URL family as the contracts PDF endpoint:

Scope: forms:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/forms/architecto/submissions/architecto/pdf?format=architecto&ttl=16" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/forms/architecto/submissions/architecto/pdf"
);

const params = {
    "format": "architecto",
    "ttl": "16",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG95H331GN5Z7EBX17BW5
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG95H331GN5Z7EBX17BW5"
}
 

Request      

GET api/v1/forms/{slug}/submissions/{code}/pdf

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

slug   string     

The form's slug. Example: architecto

code   string     

16-char submission code. Example: architecto

Query Parameters

format   string  optional    

redirect|url|stream. Default redirect. Example: architecto

ttl   integer  optional    

Signed URL lifetime seconds (60..86400). Default 86400. Example: 16

Download one uploaded field file

requires authentication

Serves whatever the submission actually holds for {field}: a stored forms/… path, OR an inline data:…;base64,… URI. Both shapes are real and both are served — the data-URI is what a drawn signature is, and what API callers necessarily wrote before an uploads endpoint existed, so refusing it would orphan real historical data.

The field's type is resolved from the submission's OWN schema snapshot, not the live form: editing a form must never change what an already-recorded submission is understood to contain.

Same three formats as the submission PDF endpoint.

Scope: forms:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/forms/architecto/submissions/architecto/files/architecto?format=architecto&ttl=16" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/forms/architecto/submissions/architecto/files/architecto"
);

const params = {
    "format": "architecto",
    "ttl": "16",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG95WYM35P3RBTJD7S2X5
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG95WYM35P3RBTJD7S2X5"
}
 

Request      

GET api/v1/forms/{slug}/submissions/{code}/files/{field}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

slug   string     

The form's slug. Example: architecto

code   string     

16-char submission code. Example: architecto

field   string     

The field's technical name. Example: architecto

Query Parameters

format   string  optional    

redirect|url|stream. Default redirect. Example: architecto

ttl   integer  optional    

Signed URL lifetime seconds (60..86400). Default 86400. Example: 16

POST api/v1/forms/{slug}/submissions

requires authentication

Example request:
curl --request POST \
    "https://elemza.com/api/v1/forms/1M0Y5PxXpaeres8a264wcFQJ_2-vyw7Mlim6DnL/submissions" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/forms/1M0Y5PxXpaeres8a264wcFQJ_2-vyw7Mlim6DnL/submissions"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Request      

POST api/v1/forms/{slug}/submissions

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

slug   string     

The slug of the form. Example: 1M0Y5PxXpaeres8a264wcFQJ_2-vyw7Mlim6DnL

Upload a file for a `file` / `image` field

requires authentication

Multipart, ONE file per call. The returned path is what you then put in data.{field} on POST /forms/{slug}/submissions. The bytes land in the form's own folder byte-identically to what the web fill flow produces, so the submissions table, the answer sheet and the image-overlay PDF all render it the same way — an API fill and a browser fill become indistinguishable downstream, which is the whole point.

Size and type come from the FIELD's own config (max_size_kb / allowed_mimes as the designer set them), clamped to the server ceiling, and the MIME is read from the file's magic bytes — never from its name or extension.

signature is deliberately not accepted here: it is drawn, and the canvas yields a data:image/png;base64,… value that goes straight into data.

Scope: forms:write + Idempotency-Key supported.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/forms/architecto/uploads" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "field=national_card"\
    --form "file=@C:\Users\pc\AppData\Local\Temp\php874C.tmp" 
const url = new URL(
    "https://elemza.com/api/v1/forms/architecto/uploads"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('field', 'national_card');
body.append('file', document.querySelector('input[name="file"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());

Request      

POST api/v1/forms/{slug}/uploads

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: multipart/form-data

Accept        

Example: application/json

URL Parameters

slug   string     

The form's slug. Example: architecto

Body Parameters

field   string     

The target field's technical name (see /schema). Example: national_card

file   file     

The file itself — multipart/form-data. Example: C:\Users\pc\AppData\Local\Temp\php874C.tmp

Forms — read-only access to v2 forms owned by the authenticated user.

Phase 5 MVP: list + show + stats. Submissions endpoint will land in Phase 5b with proper pagination + transformer.

List forms (v2 only — schema_version='2.0')

requires authentication

Paginated list of v2-schema forms owned by the calling user, most recent first. Form Builder v1 records are excluded — use the dashboard for those. Returns the standard data + meta + links envelope, consistent with the other list endpoints (API-G1, audit 2026-06 — previously a silent limit(100)).

Scope required: forms:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/forms?page=16&per_page=16" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/forms"
);

const params = {
    "page": "16",
    "per_page": "16",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG93P8VG474862STXRZ61
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG93P8VG474862STXRZ61"
}
 

Request      

GET api/v1/forms

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

page   integer  optional    

Page number. Default 1. Example: 16

per_page   integer  optional    

Items per page. Max 100. Default 50. Example: 16

Response

Response Fields

data   object     
status        

One of draft, published, archived.

renderer_type        

Form rendering mode: online (web form) or image_overlay (PDF background + overlay).

requires_signature        

Whether a response to this form produces a contract to sign.

payer        

Who pays for a response: owner (your wallet) or filler (the respondent's own wallet). A filler form CANNOT be filled through this API — see POST /forms/{slug}/submissions. Added 2026-08-24; purely additive.

signature_method        

electronic or digital (PKI certificate). Only meaningful when requires_signature is true. Added 2026-08-24; purely additive.

Show one form (metadata only — schema available via dedicated /schema endpoint in future)

requires authentication

Scope required: forms:read.

cost (added 2026-08-24) answers «what does ONE response to this form cost me?» from the same engine that takes the money — weight is the signature units a response consumes (1 for a single signer, +0.5 per extra signer, 0.5 for an استعلام-only form) and unit_cost is the Toman amount after your quota and package discount. It is present only on this endpoint, never on the list: it costs a quota and a wallet read per form.

⚠️ is_estimate: true on a payer = filler form — a different person pays each response, so the figure is the price on YOUR tariff, not one anybody will actually be charged. ok: false means the figures could not be computed; the zeros then mean «unknown», not «free».

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/forms/frm-e7465df28dd45785" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/forms/frm-e7465df28dd45785"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):


{
    "data": {
        "id": 142,
        "slug": "frm-e7465df28dd45785",
        "title": "قرارداد همکاری",
        "status": "published",
        "renderer_type": "online",
        "requires_signature": true,
        "payer": "owner",
        "signature_method": "electronic",
        "submission_count": 23,
        "views_count": 187,
        "created_at": "2026-05-10T14:32:00.000Z",
        "cost": {
            "ok": true,
            "is_free": false,
            "weight": 1.5,
            "unit_cost": 30000,
            "currency": "IRT",
            "is_estimate": false,
            "quota_unlimited": false,
            "quota_remaining": 13,
            "responses_left_on_quota": 8
        }
    }
}
 

Example response (404, Not found or not owned):


{
    "type": "https://docs.elemza.com/errors/form_not_found",
    "status": 404,
    "code": "form_not_found",
    "title_fa": "فرم یافت نشد یا متعلق به شما نیست",
    "title_en": "Form not found or not owned by the caller",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS"
}
 

Request      

GET api/v1/forms/{slug}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

slug   string     

The form's public slug. Example: frm-e7465df28dd45785

Form analytics (views/starts/submissions/conversion rates).

requires authentication

Aggregated funnel counters for one form: lifetime totals plus 7-day and 30-day windows, so you can chart trends without additional queries.

⚠️ Two engines count submissions here, and the response names both.

abandons, completion_rate and abandon_rate all derive from submissions, so the funnel adds up. completion_rate_stored is null when stored rows exceed recorded starts: the two counters disagree, and a ratio across them would be drift rather than a measurement.

Added 2026-08-20 — submissions_recorded, submissions_stored, completion_rate_stored. Purely additive; no existing field changed meaning or value.

Scope required: forms:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/forms/frm-e7465df28dd45785/stats" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/forms/frm-e7465df28dd45785/stats"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):


{
    "data": {
        "views": 187,
        "starts": 41,
        "abandons": 18,
        "submissions": 23,
        "submissions_recorded": 23,
        "submissions_stored": 25,
        "start_rate": 21.9,
        "completion_rate": 56.1,
        "completion_rate_stored": 61,
        "abandon_rate": 43.9,
        "last_submission_at": "2026-08-19T11:02:44+00:00",
        "submissions_last_7d": 4,
        "submissions_last_30d": 21
    }
}
 

Example response (404, Not found or not owned):


{
    "type": "https://docs.elemza.com/errors/form_not_found",
    "status": 404,
    "code": "form_not_found",
    "title_fa": "فرم یافت نشد یا متعلق به شما نیست",
    "title_en": "Form not found or not owned by the caller",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS"
}
 

Request      

GET api/v1/forms/{slug}/stats

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

slug   string     

The form's public slug. Example: frm-e7465df28dd45785

Form schema (fillable-field catalog)

requires authentication

Everything an integrator needs to build their own fill UI and construct a valid POST /forms/{slug}/submissions payload: field names, types, labels, required flags, options, pages, visibility conditions, and — per field — the SHAPE its value must take (value_format).

supported used to report false for file/image "because the web fill flow does not support them either". Both halves were wrong: the web renderer has had real uploads since 2026-06-22, and nothing ever rejected an inline base64 value on the API side. It now reports true for every fillable field, and value_format carries the real answer:

id is the key to keep. It is generated once and never changes — not when the field is renamed, relabelled, reordered or moved. Key your local copy of a form by id, never by name: a client keyed by name cannot tell a RENAME apart from "one field deleted, one added", and those call for opposite actions. repeat.config.ref and the fill_flow sections both reference fields by this same id.

pages describes what each field's page points at, and is never empty.

fill_flow is present only for image_overlay forms (null otherwise) and says which of the two presentations the owner chose: document draws fields at absolute coordinates on a page bitmap, while guided turns them into ordered question cards — with doc saying whether the document is shown alongside. Only guided is reasonable to reproduce outside our own renderer.

Scope required: forms:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/forms/architecto/schema" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/forms/architecto/schema"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200, An online form with one text field):


{
    "data": {
        "form": {
            "slug": "frm-e7465df28dd45785",
            "title": "قرارداد همکاری",
            "version": 12
        },
        "pages": [
            {
                "id": "page_a1b2c3d4e5f60718",
                "title": "مشخصات فردی",
                "description": null,
                "sort_order": 0,
                "visibility_condition": null
            }
        ],
        "fill_flow": null,
        "fields": [
            {
                "id": "fld_9a3f1c72e4b58d06",
                "name": "full_name",
                "type": "text",
                "label": "نام و نام خانوادگی",
                "required": true,
                "is_input": true,
                "supported": true,
                "value_format": "scalar",
                "page": "page_a1b2c3d4e5f60718",
                "help_text": null,
                "placeholder": null,
                "default_value": null,
                "options": null,
                "config": {},
                "has_visibility_condition": false,
                "visibility_condition": null,
                "is_formula": false,
                "formula": null,
                "validations": [],
                "sort_order": 0
            }
        ]
    }
}
 

Request      

GET api/v1/forms/{slug}/schema

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

slug   string     

The form's public slug. Example: architecto

Response

Response Fields

data   object     
fields   object     
id        

Stable field identifier (fld_ + 16 hex). Survives renames — key your local copy by this, never by name.

formula        

The expression a computed field evaluates; null for every other type.

server_computed        

true when the formula reads a field the respondent is not shown, so it cannot be computed in the browser — display «calculated after submission» instead of evaluating it. false for every other field.

config        

Per-type constraints the designer set (e.g. max_size_kb, allowed_mimes, min_year_offset). Only keys an integrator needs; omitted when unset.

pages[]        

The form's pages, in display order. Never empty.

fill_flow        

Image-overlay forms only (null otherwise): style is document or guided, doc is live or hidden, plus the ordered sections and any unassigned field ids.

Verify a query field (Shahkar / legal entity)

requires authentication

Runs the SAME server-side verification the web renderer's «استعلام» buttons run, and writes the same server-side binding that POST /forms/{slug}/submissions checks — echo the returned value back inside data.{field} when you submit, FROM THE SAME IP.

The form OWNER's daily Shahkar quota pays for the lookup (identical to web). Sandbox tokens short-circuit to matched=true without any provider call.

Every lookup (Shahkar, civil, postal, legal entity, and the company / owner inquiries: query_company_iban, query_sayad_cheque with the form owner as holder) counts against the form's hourly lookup ceiling, shared with the public form page. Past it the answer is 429 with code inquiry_rate_limited; retry later. Sandbox lookups are not counted.

Every lookup is billed to the form owner and counts against the owner's daily inquiry allowance; past it the answer is 422 verify_failed («سقفِ امروزِ استعلامِ فرم‌های شما پر شده است»).

An inquiry ABOUT A PERSON (query_guild_licence, query_iban_owner, query_military_service, query_sana, query_card_owner, query_bounced_cheques, and query_sayad_cheque with the filler as holder — its schema value_format is form_page_only) runs only on the form page, with that person's own confirmation: the answer is 409 with code inquiry_requires_form_page and meta.public_url. Send the respondent there.

Scope required: forms:write.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/forms/architecto/verify-field" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"field\": \"architecto\",
    \"values\": {
        \"mobile\": \"09121234567\",
        \"national_code\": \"0010350829\"
    }
}"
const url = new URL(
    "https://elemza.com/api/v1/forms/architecto/verify-field"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "field": "architecto",
    "values": {
        "mobile": "09121234567",
        "national_code": "0010350829"
    }
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Request      

POST api/v1/forms/{slug}/verify-field

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

slug   string     

The form's public slug. Example: architecto

Body Parameters

field   string     

The query field's name. Example: architecto

values   object     

Raw values of the referenced input fields.

Meta — health, identity, quota, cost

Health check

Liveness + shallow dependency probe. No authentication required. Returns 200 when every dependency answers, 503 when one does not.

── 🩸 چرا این متد عوض شد (۱۴۰۵/۰۶/۰۹) ───────────────────────────────────────────────

تا امروز این کنترلر ۳۶ خط بود و همیشه ۲۰۰ برمی‌گرداند، بدونِ یک تماس با دیتابیس، ردیس یا صف. پاسخِ زندهٔ دیروز:

{"status":"ok","time":"2026-08-30T20:43:08.244Z","version":"v1.0.0"}

یعنی تنها چیزی که ثابت می‌کرد این بود که php-fpm زنده است و مسیریابی کار می‌کند. اگر پستگرس می‌خوابید، این endpoint همچنان "status":"ok" می‌گفت — و اولین چیزی که یک مشتریِ یکپارچه‌ساز به آن وصل می‌شود همین است. یک probeِ سلامتی که نمی‌تواند ناسالم بگوید، از نداشتنش بدتر است، چون کسی به آن تکیه می‌کند.

── آنچه این عمداً نمی‌سنجد ──────────────────────────────────────────────────────

سلامتِ عمیق (پندار، جیبیت، کاوه‌نگار، فضای دیسک) این‌جا نیست. آن نیازِ یک مسیرِ احرازشدهٔ جدا است، و افزودنِ مسیر یعنی نوشتن در routes/api.php که مالکیتِ بستهٔ ۲ است. تا آن‌وقت، پاسخِ این‌جا صریحاً می‌گوید چه چیزی را پوشش می‌دهد ("scope":"shallow") تا کسی آن را عمیق‌تر از آنچه هست نخواند.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/health" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/health"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200):


{
    "status": "ok",
    "time": "2026-05-11T11:53:29.399Z",
    "version": "v1.0.0",
    "scope": "shallow",
    "checks": {
        "database": "ok",
        "cache": "ok",
        "queue": "ok"
    }
}
 

Example response (503):


{
    "status": "degraded",
    "time": "2026-05-11T11:53:29.399Z",
    "version": "v1.0.0",
    "scope": "shallow",
    "checks": {
        "database": "fail",
        "cache": "ok",
        "queue": "unknown"
    }
}
 

Request      

GET api/v1/health

Headers

Content-Type        

Example: application/json

Accept        

Example: application/json

Caller identity

requires authentication

Returns information about the authenticated token, its owner user, and the billing context (wallet balance, org root). Any valid token can call this — no specific scope required.

Use the token.mode field to confirm whether your token is in live mode (charges your wallet, real KYC/SMS) or test sandbox mode (zero wallet impact, mocked side effects). wallet_balance is always in tomans (IRR/10).

🩸 You do not have to call this endpoint to find out. Every authenticated API response carries X-Emza-Mode: live|test, including error envelopes — so an integration can assert on it continuously rather than checking once at setup. That header was added on 1405/06/10 after a live site ran for seven hours on a sandbox token: every response was a 200, every contract was mocked, no SMS reached any signer, and nothing on the wire said so.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/me" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/me"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200, Live token):


{
    "data": {
        "token": {
            "id": "42",
            "name": "production-server-2026",
            "mode": "live",
            "scopes": [
                "contracts:read",
                "contracts:write",
                "webhooks:manage"
            ],
            "ip_whitelist": [
                "203.0.113.5/32"
            ],
            "expires_at": "2027-01-01T00:00:00.000Z",
            "last_used_at": "2026-05-13T18:00:42.000Z"
        },
        "user": {
            "id": 1234,
            "name": "آرش بنائیان چمله",
            "type": "personal",
            "is_org_root": false,
            "org_root_id": null
        },
        "billing_actor_user_id": 1234,
        "wallet_balance": 849310
    }
}
 

Example response (200, Sandbox/test token):


{
    "data": {
        "token": {
            "id": "13",
            "name": "ci-tests-sandbox",
            "mode": "test",
            "scopes": [
                "*"
            ],
            "ip_whitelist": [],
            "expires_at": null,
            "last_used_at": "2026-05-13T17:52:23.000Z"
        },
        "user": {
            "id": 1234,
            "name": "آرش بنائیان چمله",
            "type": "personal",
            "is_org_root": false,
            "org_root_id": null
        },
        "billing_actor_user_id": 1234,
        "wallet_balance": 849310
    }
}
 

Request      

GET api/v1/me

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Response

Response Fields

data   object     
token   object     
mode        

Either live or test. Sandbox tokens never debit the wallet.

scopes   string[]     

of granted abilities. ["*"] means full access.

ip_whitelist        

If non-empty, requests from other IPs are rejected with 403 ip_not_allowed. Five failures within 1h auto-revoke the token.

user   object     
is_org_root        

True when this user is the root of a Sub-Organization tree (can invite sub-users).

org_root_id        

ID of the org root if this user is a member, else null.

billing_actor_user_id        

The wallet that pays for this request. Same as user.id for solo users; may be org_root_id for org members with auto_charge_from_parent=true.

wallet_balance        

Current wallet balance in tomans (Iranian Rials ÷ 10).

capabilities   object     
signer_pays        

True when POST /contracts accepts payer_mode=signer or designated (signers pay the signature fee). When false, those values are rejected with 422 payer_mode_unavailable. The mode is fixed on each contract at creation, so existing contracts keep theirs if this later turns false.

signer_pays_window_days        

Days a paying signer has to pay and sign before the contract is cancelled and your commitment is kept.

legal_entities        

Companies this token may send contracts on behalf of. Pass an id as legal_entity_id to POST /contracts. can_act is false when the company's registered board term has expired.

trade_names        

Your trade names (نامِ تجاری) — pass an id as trade_name_id to POST /contracts to send one contract under that shop name. Each has can_use (lendable right now) and, when false, why_not (Persian). A trade name is shown BESIDE your own name («فروشگاه مهر (علی رضایی)»); you stay the party of the contract. It is never chosen by omitting the field.

sender_default        

{as, name} — what a contract goes out under when you send neither legal_entity_id nor trade_name_id: as is company (your account default), organisation (a lending organisation member) or self.

default_legal_entity_id        

The company a contract goes out under when you OMIT legal_entity_id on POST /contracts — set in the panel («شرکت‌های من» → «پیش‌فرضِ من باشد»). null means contracts you do not attribute are sent under your own personal name. Send legal_entity_id: 0 to force one contract to be personal while a default is set. If this id is NOT present in legal_entities, your default has become unusable and contract creation will fail with 422 default_legal_entity_unusable until you fix it in the panel — it will never silently fall back to your personal name. If it IS present but its can_act is false (board term expired), an omitted legal_entity_id fails with 422 legal_entity_board_expired for the same reason: check can_act, not just the id.

Current quota

requires authentication

Returns the caller's current-month signature quota usage + remaining, package tier, and today's Shahkar verification credits.

Quota semantics:

Shahkar credits are separate from signature quota. Daily allowance by package (Free=3, Bronze=5, Silver=10, Gold=20). Once exhausted, the client must purchase batch top-ups before further Shahkar verifications.

Scope required: contracts:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/quota" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/quota"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200, Bronze user mid-month):


{
    "data": {
        "service": "electronic_signature",
        "period_start": "2026-05-01T00:00:00.000Z",
        "period_end": "2026-05-31T23:59:59.999Z",
        "package": {
            "slug": "bronze",
            "name": "برنزی"
        },
        "free_quota": 30,
        "used": 17,
        "remaining": 13,
        "shahkar": {
            "free_limit": 5,
            "used_today": 2,
            "free_remaining": 3,
            "extra_credits": 0,
            "extra_remaining": 0,
            "allowed": true
        }
    }
}
 

Example response (200, Gold (unlimited)):


{
    "data": {
        "service": "electronic_signature",
        "period_start": "2026-05-01T00:00:00.000Z",
        "period_end": "2026-05-31T23:59:59.999Z",
        "package": {
            "slug": "gold",
            "name": "طلایی"
        },
        "free_quota": 0,
        "used": 412,
        "remaining": null,
        "shahkar": {
            "free_limit": 20,
            "used_today": 4,
            "free_remaining": 16,
            "extra_credits": 0,
            "extra_remaining": 0,
            "allowed": true
        }
    }
}
 

Example response (200, No active package (pay-per-use)):


{
    "data": {
        "service": "electronic_signature",
        "period_start": "2026-05-01T00:00:00.000Z",
        "period_end": "2026-05-31T23:59:59.999Z",
        "package": null,
        "free_quota": 0,
        "used": 0,
        "remaining": 0,
        "shahkar": {
            "free_limit": 0,
            "used_today": 0,
            "free_remaining": 0,
            "extra_credits": 0,
            "extra_remaining": 0,
            "allowed": false
        }
    }
}
 

Request      

GET api/v1/quota

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Response

Response Fields

data   object     
free_quota        

Monthly signature allowance from active package. Zero if package expired or none.

used        

Signatures recorded this period (since package_started_at).

remaining        

Signatures left this period. null means unlimited (Gold).

shahkar   object     
allowed        

Whether the user may attempt a Shahkar verification right now. False = quota exhausted, must purchase batch top-up.

Cost estimate

requires authentication

What sending a contract to N signers will debit, computed by the same engine the send uses (SendCost — the charge's own price function and wallet decision), without committing anything. Use it before POST /contracts or POST /contracts/{code}/signers.

Scope required: contracts:read.

The old shape is unchanged. Called with only signers (and optionally discount_code) the response is exactly what it always was: an electronic signature, the caller's own wallet, no privacy. Passing any of signature_method, is_private, payer_mode, payers or contract adds service_type, payer_mode, existing_signers, share and payment_plan.

payment_plan.can_cover is the truthful «will this send go through». sufficient_balance keeps its old meaning — the caller's OWN wallet against total_cost — so a member of an organisation whose send the organisation wallet pays reads sufficient_balance: false and payment_plan: {source: "parent_wallet", can_cover: true}. The organisation wallet's balance is never returned.

total_cost is what leaves a wallet at send time. In payer_mode=creator it is the creator's charge (free quota applied). In signer / designated it is the creator's commitment — the advance the creator puts down for the other signers' shares (quota is not used in these modes, so the quota/tariff keys are null); the split is in share.

Discount codes. The send applies the code stored on the contract — the one given as discount_code to POST /contracts (or typed in the panel). With contract the estimate reads that code itself, so it is the amount that will be charged. Without contract, discount_code prices a send for a contract you would create with that code; here an unusable code is not an error — it simply gives discount_amount: 0 — whereas POST /contracts rejects it.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/cost-estimate?signers=3&discount_code=WELCOME10&signature_method=electronic&is_private=false&payer_mode=creator&payers=1&creator_is_signer=false&creator_pays=false&contract=ABCD1234EFGH5678" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/cost-estimate"
);

const params = {
    "signers": "3",
    "discount_code": "WELCOME10",
    "signature_method": "electronic",
    "is_private": "false",
    "payer_mode": "creator",
    "payers": "1",
    "creator_is_signer": "false",
    "creator_pays": "false",
    "contract": "ABCD1234EFGH5678",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200, extended (any new parameter)):


{
    "data": {
        "tariff_cost": 55000,
        "quota_used": 0,
        "billable_units": 1,
        "overage_cost": 55000,
        "discount_amount": 0,
        "tax_amount": 5500,
        "total_cost": 60500,
        "currency": "IRT",
        "discount_code": null,
        "package": null,
        "wallet_balance": 20000,
        "wallet_balance_after": 0,
        "sufficient_balance": false,
        "service_type": "electronic_signature",
        "payer_mode": "creator",
        "existing_signers": 0,
        "share": null,
        "payment_plan": {
            "source": "parent_wallet",
            "can_cover": true,
            "blocked_reason": null,
            "message_fa": "موجودی شما کافی نیست — هزینه از کیفِ سازمان پرداخت خواهد شد."
        }
    }
}
 

Example response (404, contract not yours / unknown):


{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "قرارداد یافت نشد",
    "title_en": "Contract not found",
    "request_id": "01J..."
}
 

Example response (422, parameter contradicts the contract):


{
    "type": "https://docs.elemza.com/errors/estimate_contract_mismatch",
    "status": 422,
    "code": "estimate_contract_mismatch",
    "title_fa": "پارامترِ ارسالی با خودِ قرارداد نمی‌خواند",
    "title_en": "A parameter contradicts the contract",
    "errors": [
        {
            "field": "signature_method",
            "code": "mismatch",
            "title_fa": "این قرارداد digital است",
            "title_en": "This contract is digital"
        }
    ],
    "request_id": "01J..."
}
 

Request      

GET api/v1/cost-estimate

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

signers   integer     

Number of NEW signers in this send (1-20). Example: 3

discount_code   string  optional    

Optional discount code — the one you will pass to POST /contracts. Example: WELCOME10

signature_method   string  optional    

electronic (default) or digital. Example: electronic

is_private   string  optional    

A private contract is paid from the caller's own wallet only, never the organisation's: true/false/1/0. Example: false

payer_mode   string  optional    

Who pays: creator (default), signer (split among all signers) or designated (split among payers of them). Example: creator

payers   integer  optional    

Only with payer_mode=designated: how many of the signers pay (1..signers). Example: 1

creator_is_signer   string  optional    

You are one of the signers yourself (your own row will carry is_creator on POST /contracts/{code}/signers): true/false/1/0. It changes the figure only when the cost is shared: with payer_mode=signer you then pay your own share in full at send, plus the reserve for the others. The figure assumes your own row is the FIRST of the paying rows you send; elsewhere in the list it can differ by the rounding remainder (at most payers − 1 toman). Example: false

creator_pays   string  optional    

With creator_is_signer=true and payer_mode=designated: your own row is one of the payers (is_payer); at least one payer must be someone else. In the other modes it only states what is already true (signer: every signer pays, you included — false is refused; creator: you pay everything). Example: false

contract   string  optional    

A draft contract YOU created (16-char code): its current signers are counted as existing (extra signers are priced as such), and its signature method, privacy and payer mode are used. An explicit parameter that contradicts the contract ⇒ 422 estimate_contract_mismatch; someone else's or unknown ⇒ 404. Example: ABCD1234EFGH5678

Signers

Signer endpoints for a contract.

Phase 1 = read-only (index + show). Resend + delete = Phase 2 (mutations).

Spec: docs/api-master-plan/02-endpoint-surface.md (Signer endpoints).

List signers

requires authentication

Lists all signers on a contract. PII (mobile, national_code) is masked unless the caller's token has signers:read_pii scope.

Scope: contracts:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/contracts/architecto/signers" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/signers"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG92AFXQAXH954QHS42A6
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG92AFXQAXH954QHS42A6"
}
 

Request      

GET api/v1/contracts/{code}/signers

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char contract code. Example: architecto

Get signer

requires authentication

Detailed view of a single signer. PII masked unless token has signers:read_pii.

Scope: contracts:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/contracts/architecto/signers/DEF456GHJ789KLM" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/signers/DEF456GHJ789KLM"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG92KFSNW8561ASM220XZ
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG92KFSNW8561ASM220XZ"
}
 

Request      

GET api/v1/contracts/{code}/signers/{slug}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char contract code. Example: architecto

slug   string     

Per-signer slug. Example: DEF456GHJ789KLM

Add signers

requires authentication

Adds one or more signers to a draft contract. Runs mandatory Shahkar pre-validation (mobile ↔ national_code match) per signer in production. On success, contract transitions to waiting_signature and SMS dispatch jobs are queued for first-order signers.

The contract must have its document first. A contract created as JSON without file/source (the multi-step flow) has none until POST /contracts/{code}/files; adding signers to it is 422 document_required — no signer is added, nothing is charged, nobody is texted, and the contract stays a draft (meta.reason: no_document). A document that could not be processed (GET /contracts/{code}/processing answers step=error) is no document either (meta.reason: document_failed): upload a corrected file with POST /contracts/{code}/files. Add signers once the document is ready: after the upload, wait until GET /contracts/{code}/processing answers ready=true (or the contract.processing.completed webhook) — the signing SMS does not wait for the pages, so a signer reached earlier can open a page that is not ready yet. To skip the wait, send the signers inline with the file in one POST /contracts. A template_id gives a contract signature boxes, not a document. Like every 4xx this answer is stored under your Idempotency-Key: attach the document, then send the signers with a new key.

A contract created with signing_deadline_at is re-checked here against the CURRENT time: if the deadline has passed or is less than an hour away this is 422 signing_deadline_passed — no signer is added, charged or texted.

An attached document — an amendment or a rescission of a completed contract (parent_contract set) — takes no signers here, in any status: its signers are the original contract's parties, fixed when it is made. 409 attached_document_signers_fixed, before any other check; nothing is added, charged or texted.

An electronic replacement of a digital contract (POST /contracts with replaces; its replaces is set) takes no signers here while it is a draft: its roster is the replaced contract's, copied by the system once the document is processed — 409 replacement_signers_pending; nothing is added, charged or texted. Once the roster has arrived the contract is waiting for signatures and, like any such contract, takes no new batch.

A digital contract created with signer_mode checks this batch against it: solo takes exactly one signer, multi at least two — otherwise 422 signer_mode_mismatch, before any identity check, charge or row.

When the identity registry itself does not answer (an outage — nothing is known about the signers), the answer is 503 identity_service_unavailable with Retry-After: no signer was added and nothing was charged, and the same request can simply be sent again. 422 shahkar_mismatch is only for an answer that says the mobile and the national code do not belong together.

When your account's DAILY identity-inquiry quota is used up (each mismatch the registry answers counts against it), nobody is asked and the answer is 429 identity_inquiry_quota_exhausted with Retry-After (seconds until the quota opens at the start of the next day) and meta.resets_at: no signer was added and nothing was charged. It says nothing about the signers' data. Like every 429 it is not stored under your Idempotency-Key — send the same request again after the reset, or sooner once an inquiry batch is bought in the panel (GET /quota → shahkar.allowed). An account whose daily allowance is ZERO (every day starts used up) gets no promise of a reset: 403 identity_inquiry_quota_exhausted with meta.resets: false and no Retry-After — buy an inquiry batch in the panel, then send the same request again (it is not stored under your Idempotency-Key).

Scope: signers:write.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/contracts/architecto/signers" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"signers\": [
        \"architecto\"
    ],
    \"on_company_warning\": \"refuse\"
}"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/signers"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "signers": [
        "architecto"
    ],
    "on_company_warning": "refuse"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (403, your account has NO daily identity-inquiry allowance (every day starts used up) — nobody asked, nothing added or charged; no Retry-After: buy an inquiry batch in the panel, then send the same request again):


{
    "type": "https://docs.elemza.com/errors/identity_inquiry_quota_exhausted",
    "status": 403,
    "code": "identity_inquiry_quota_exhausted",
    "title_fa": "حسابِ شما سهمیهٔ رایگانِ روزانه برای استعلامِ هویت ندارد، پس هویتِ امضاکنندگان استعلام نشد — این پاسخ دربارهٔ اطلاعاتِ آن‌ها نیست. هیچ امضاکننده‌ای اضافه نشد و هزینه‌ای کسر نشد. این سقف با گذشتِ روز باز نمی‌شود؛ در پنل، در صفحهٔ ساختِ قرارداد، بستهٔ استعلامِ اضافه بخرید و سپس همین درخواست را دوباره بفرستید.",
    "title_en": "Your account has no daily identity-inquiry allowance, so the signers' identities were not checked — this says nothing about their data. No signer was added and nothing was charged. Waiting will not open it: buy an inquiry batch in the panel, then send the same request again.",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS",
    "meta": {
        "resets": false
    }
}
 

Example response (409, an electronic replacement (`replaces` set) whose roster the system is still copying — nothing added, charged or texted):


{
    "type": "https://docs.elemza.com/errors/replacement_signers_pending",
    "status": 409,
    "code": "replacement_signers_pending",
    "title_fa": "این قرارداد نسخهٔ الکترونیکِ یک قراردادِ دیجیتال است و امضاکنندگانش همان امضاکنندگانِ قراردادِ قبلی‌اند که سامانه پس از پردازشِ سند خودش اضافه می‌کند؛ امضاکننده‌ای اضافه نشد. صبر کنید تا GET /contracts/{code}/processing آماده‌بودن را بگوید.",
    "title_en": "This contract is the electronic replacement of a digital one; its signers are the replaced contract's, added by the system once the document is processed, so no signer was added. Wait for GET /contracts/{code}/processing to say ready."
}
 

Example response (409, an attached document (an amendment or a rescission of a completed contract) — its signers are fixed; nothing added, charged or texted):


{
    "type": "https://docs.elemza.com/errors/attached_document_signers_fixed",
    "status": 409,
    "code": "attached_document_signers_fixed",
    "title_fa": "این سند پیوستِ قراردادِ دیگری است (الحاقیه یا اقاله‌نامه)؛ امضاکنندگانش همان طرفینِ قراردادِ اصلی‌اند و هنگامِ ساختِ سند تعیین شده‌اند، پس امضاکننده‌ای اضافه نشد.",
    "title_en": "This is an attached document (an amendment or a rescission) of another contract; its signers are the parties of the original contract, fixed when it was made, so no signer was added.",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS"
}
 

Example response (409, the contract is no longer a draft — signers were already added (waiting for signatures) or it has ended; also the loser of two batches sent at the same moment — nothing added, charged or texted):


{
    "type": "https://docs.elemza.com/errors/wrong_contract_status",
    "status": 409,
    "code": "wrong_contract_status",
    "title_fa": "فقط روی قرارداد در وضعیت پیش‌نویس می‌توان امضاکننده اضافه کرد",
    "title_en": "Only draft contracts accept new signers"
}
 

Example response (422, the contract has no document yet (created as JSON without file or source) — nothing added, charged or texted; the contract stays draft):


{
    "type": "https://docs.elemza.com/errors/document_required",
    "status": 422,
    "code": "document_required",
    "title_fa": "این قرارداد هنوز سندی ندارد؛ ابتدا فایلِ قرارداد را پیوست کنید — با فیلدِ file (multipart) در همان POST /contracts، یا با POST /contracts/{code}/files — و وقتی GET /contracts/{code}/processing آماده‌بودن (ready) را گفت، امضاکنندگان را اضافه کنید؛ یا امضاکنندگان را همراهِ فایل در همان POST /contracts بفرستید. هیچ امضاکننده‌ای اضافه نشد، پیامکی نرفت و هزینه‌ای کسر نشد.",
    "title_en": "This contract has no document yet. Attach it — the multipart `file` field of POST /contracts, or POST /contracts/{code}/files — and add the signers once GET /contracts/{code}/processing says ready; or send the signers inline with the file in one POST /contracts. No signer was added, nothing was charged and nobody was texted.",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS",
    "meta": {
        "reason": "no_document",
        "contract_status": "draft",
        "files": "https://elemza.com/api/v1/contracts/ABCD1234EFGH5678/files"
    }
}
 

Example response (429, your account's daily identity-inquiry quota is used up — nobody was asked, nothing added or charged; header Retry-After: seconds until the reset):


{
    "type": "https://docs.elemza.com/errors/identity_inquiry_quota_exhausted",
    "status": 429,
    "code": "identity_inquiry_quota_exhausted",
    "title_fa": "سقفِ روزانهٔ استعلامِ هویتِ حسابِ شما پر شده است، پس هویتِ امضاکنندگان استعلام نشد — این پاسخ دربارهٔ اطلاعاتِ آن‌ها نیست. هیچ امضاکننده‌ای اضافه نشد و هزینه‌ای کسر نشد. سقف در آغازِ روزِ بعد دوباره باز می‌شود (زمانش در Retry-After و meta.resets_at)؛ یا در پنل، در صفحهٔ ساختِ قرارداد، بستهٔ استعلامِ اضافه بخرید. سپس همین درخواست را دوباره بفرستید.",
    "title_en": "Your account's daily identity-inquiry quota is used up, so the signers' identities were not checked — this says nothing about their data. No signer was added and nothing was charged. The quota opens again at the start of the next day (Retry-After, meta.resets_at), or sooner after buying an inquiry batch in the panel; then send the same request again.",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS",
    "meta": {
        "retry_after_seconds": 30512,
        "resets_at": "2026-11-19T00:00:00+03:30"
    }
}
 

Request      

POST api/v1/contracts/{code}/signers

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char contract code. Example: architecto

Body Parameters

signers   string[]     

Array of signer objects. A contract whose signers were sent WITH it (inline on a one-shot POST /contracts) together with signer_mode or template_slot takes no further signers here: 409 signers_sent_with_contract.

first_name   string     

Example: architecto

last_name   string     

Example: architecto

mobile   string     

Iran mobile regex 09XXXXXXXXX. Example: 09121234567

national_code   string  optional    

10-digit valid Iran national code. Required unless identity_document=fida (then omitted). Example: architecto

identity_document   string  optional    

national_code (default) or fida — a foreign national identified by their FIDA (کدِ فراگیرِ اتباع). A FIDA signer is accepted only on an electronic contract, for a natural person, while the foreigners' registry is available (403 inquiry_not_available / 503 inquiry_temporarily_unavailable otherwise; 422 foreign_signer_not_on_digital on a digital contract). Their identity is checked when they sign. Example: national_code

fida   string  optional    

Required when identity_document=fida: 6–16 digits. Example: architecto

guardian_required   boolean  optional    

The signer is under 18: no Shahkar is made for this row at creation, and at signing their legal guardian proves their own identity (Shahkar + civil registry) and the relation (documents reviewed by support) and signs for them. Electronic contracts and Iranian natural persons only (422 minor_not_on_digital / minor_must_be_iranian_natural). Give the signer a mobile other than the guardian's. Example: false

identity_assurance   string  optional    

standard (default) or face_liveness — «تأییدِ چهره و زنده‌بودن»: at signing, after the usual identity check, the signer records a few-second selfie video reading a sentence aloud; liveness, a face match against the civil-registry photo of their national code, and speech are checked. Charged at send per signer from the sender's wallet (the tariff face_liveness_query, two attempts; refunded on cancel when no answer was billed). Electronic contracts, Iranian natural persons, and only while the service is open (403 inquiry_not_available / 503 inquiry_temporarily_unavailable; 422 face_liveness_not_on_digital / face_liveness_not_for_foreign / face_liveness_natural_only). The signer's identity.liveness block reports the outcome (passed / waived / pending). Example: standard

email   string  optional    

Optional. Example: gbailey@example.net

order   integer  optional    

Default 0 (parallel signing). Example: 16

signer_type   string  optional    

natural|legal. Default natural. Example: architecto

legal_national_code   string  optional    

Required when signer_type=legal (11-digit company tax ID). On your OWN row (is_creator) it must be the company the contract was created on behalf of (legal_entity_id, or your account default); any other company there is 422 creator_company_not_acting_entity and no signer is added. If you no longer actively represent that company, or its board term has ended since the contract was created, the row is refused with the same two codes as POST /contracts: 422 legal_entity_not_accessible / legal_entity_board_expired. Example: architecto

legal_company_name   string  optional    

Required when signer_type=legal. Example: architecto

is_payer   boolean  optional    

Only when the contract was created with payer_mode=designated: this signer pays a share of the signature fee on the signing page. At least one signer other than you must be flagged (422 payer_required); sending it on any other contract is 422 payer_not_applicable. On a signer/designated contract all signers must be added in ONE batch; a contract that already has signers refuses a second batch (409 contract_error). Use the same kind of token (live/test) that created the contract, else 409 sandbox_mode_mismatch. Example: true

template_slot   integer  optional    

Which signature box of the contract's template is this signer's: 1..the template's highest box (each box to one signer) or 0 for free placement. Only when the contract was created with a template of at least two boxes; otherwise, for a box the template does not have, or a box given twice, 422 and no signer is added. Signers without it get the lowest free box; omit it on every signer and boxes follow the signers' order, as before. Example: 1

on_company_warning   string  optional    

What to do when a company signer has a high registry warning (company not found / dissolved / in liquidation / not active, board term ended, signer not on the current board): continue (default — the contract is sent and each signer's legal.company_check carries the warning) or refuse (409 company_check_warning, before any identity check, charge or row). Example: refuse

Resend signing link SMS

requires authentication

Re-sends the signing-link SMS to a waiting signer. Rate-limited to 3 per 5 minutes per signer (returns 429 rate_limit_exceeded). Use the same kind of token (live/test) that created the contract, else 409 sandbox_mode_mismatch and nothing is sent. A contract with no document gets no signing link: 422 document_required, nothing sent, no resend spent.

Scope: signers:write.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/contracts/architecto/signers/architecto/resend" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/signers/architecto/resend"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Example response (422, the contract has no document (never attached, or it could not be processed) — no SMS sent, no resend spent):


{
    "type": "https://docs.elemza.com/errors/document_required",
    "status": 422,
    "code": "document_required",
    "title_fa": "سندِ این قرارداد پردازش نشد و بدونِ سند برای امضا فرستاده نمی‌شود؛ فایلِ درست را با POST /contracts/{code}/files دوباره بفرستید و وقتی GET /contracts/{code}/processing آماده‌بودن (ready) را گفت، امضاکنندگان را اضافه کنید. هیچ امضاکننده‌ای اضافه نشد، پیامکی نرفت و هزینه‌ای کسر نشد.",
    "title_en": "This contract's document could not be processed, so it has no document. Upload a corrected file with POST /contracts/{code}/files, wait until GET /contracts/{code}/processing says ready, then add the signers. No signer was added, nothing was charged and nobody was texted.",
    "meta": {
        "reason": "document_failed",
        "contract_status": "waiting_signature",
        "files": "https://elemza.com/api/v1/contracts/ABCD1234EFGH5678/files"
    }
}
 

Request      

POST api/v1/contracts/{code}/signers/{slug}/resend

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char contract code. Example: architecto

slug   string     

Per-signer slug. Example: architecto

Remove signer

requires authentication

Removes a signer from a contract. Only allowed when:

Scope: signers:write.

Example request:
curl --request DELETE \
    "https://elemza.com/api/v1/contracts/architecto/signers/architecto" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/contracts/architecto/signers/architecto"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());

Example response (204):

Empty response
 

Example response (409, an electronic replacement whose roster the system is still copying — nothing removed):


{
    "type": "https://docs.elemza.com/errors/replacement_signers_pending",
    "status": 409,
    "code": "replacement_signers_pending",
    "title_fa": "امضاکنندگانِ این نسخهٔ الکترونیک هنوز از قراردادِ قبلی منتقل نشده‌اند؛ امضاکننده‌ای حذف نشد. پس از آماده‌شدنِ قرارداد دوباره امتحان کنید.",
    "title_en": "This replacement's signers have not been copied from the replaced contract yet; no signer was removed. Try again once the contract is ready."
}
 

Example response (409, an attached document (an amendment or a rescission of a completed contract) — none of its signers can be removed; cancel the whole document instead):


{
    "type": "https://docs.elemza.com/errors/attached_document_signers_fixed",
    "status": 409,
    "code": "attached_document_signers_fixed",
    "title_fa": "این سند پیوستِ قراردادِ دیگری است (الحاقیه یا اقاله‌نامه)؛ امضاکنندگانش همان طرفینِ قراردادِ اصلی‌اند و هیچ‌کدام حذف نمی‌شود. اگر نمی‌خواهید ادامه دهید، کلِ سند را لغو کنید.",
    "title_en": "This is an attached document (an amendment or a rescission) of another contract; its signers are the parties of the original contract and none can be removed. Cancel the whole document instead.",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS"
}
 

Request      

DELETE api/v1/contracts/{code}/signers/{slug}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

16-char contract code. Example: architecto

slug   string     

Per-signer slug. Example: architecto

Templates

Template endpoints — read-only in v1.0. CRUD lands in v1.x.

Spec: docs/api-master-plan/02-endpoint-surface.md (Template endpoints).

List templates

requires authentication

Lists contract templates the caller can use.

view_scope options:

Scope: templates:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/templates?view_scope=architecto&active=&page=16&per_page=16" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/templates"
);

const params = {
    "view_scope": "architecto",
    "active": "0",
    "page": "16",
    "per_page": "16",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG97SP3A7BXDG6GEM9PAE
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG97SP3A7BXDG6GEM9PAE"
}
 

Request      

GET api/v1/templates

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

view_scope   string  optional    

self | shared_from_parent | all_org. Default self. Example: architecto

active   boolean  optional    

Filter by active status. Example: false

page   integer  optional    

Example: 16

per_page   integer  optional    

Max 100. Default 20. Example: 16

Get template

requires authentication

Full template shape with embedded positions + page geometry + sample preview link.

Scope: templates:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/templates/architecto" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/templates/architecto"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
x-request-id: 01M7RWG983V8QES7ZAACGMA3EP
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "منبع یافت نشد",
    "title_en": "Resource not found",
    "request_id": "01M7RWG983V8QES7ZAACGMA3EP"
}
 

Request      

GET api/v1/templates/{id}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   string     

The ID of the template. Example: architecto

template   integer     

Template ID. Example: 16

Template page preview

requires authentication

NOT IMPLEMENTED YET — returns 501 preview_not_available. The signed page-preview URL lands in a later phase (Storage::temporaryUrl). Documented as a stub so merchants do not code against a fake url:null 200.

Scope: templates:read.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/templates/16/preview/16" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/templates/16/preview/16"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG98AXEH2KSPYMJT94TW5
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG98AXEH2KSPYMJT94TW5"
}
 

Example response (501, Stub — not implemented):


{
    "status": 501,
    "code": "preview_not_available"
}
 

Request      

GET api/v1/templates/{template}/preview/{page}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

template   integer     

Template ID. Example: 16

page   integer     

Page number (1-indexed). Example: 16

Verification

Verify a tracking code

Public — no token. The same answer as the «استعلام سند» page on elemza.com: whether a document with this tracking code exists, its status, and — only when it is completed — its title, completion time, signer count and the platform seal's time.

valid is true only for a completed contract that is not a test (sandbox) contract. A test contract was signed under a pat_test_* token with no real identity check; it answers is_test: true, valid: false whatever its status. A contract that is not completed returns its status only.

company_signatures (completed, non-test contracts only) lists, for each signature made on behalf of a company, the company and the basis the platform recorded for that signer's authority — never a person's name.

identity_summary (completed, non-test contracts only) counts how the signers' identities were checked — category is one of registry (Shahkar and the civil registry), registry_no_mobile (the civil registry; the mobile ↔ national-code match was not made at signing), foreigners, otp_only, manual, account, guardian — with a Persian label. Counts only, never a name.

No signer names, mobiles or national codes are ever returned. Dates are ISO-8601 with a Jalali twin (Y/m/d H:i, Tehran time). Rate limit: 60 requests per minute per IP (throttle:api-anon).

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/verify/ABCD1234EFGH5678" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/verify/ABCD1234EFGH5678"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200, completed):


{
    "data": {
        "code": "ABCD1234EFGH5678",
        "found": true,
        "status": "completed",
        "is_test": false,
        "valid": true,
        "completed_at": "2026-08-20T10:00:00+03:30",
        "completed_at_jalali": "1405/05/29 10:00",
        "signers_count": 2,
        "sealed_at": null,
        "sealed_at_jalali": null,
        "title": "قرارداد همکاری",
        "company_signatures": [
            {
                "company": "«آرین تجارت پارس»",
                "basis": "حقِ امضای منفرد طبقِ مرجعِ ثبت"
            }
        ],
        "identity_summary": [
            {
                "category": "registry",
                "label": "شاهکار و ثبت‌احوال",
                "count": 2
            }
        ]
    }
}
 

Example response (200, test contract):


{
    "data": {
        "code": "ABCD1234EFGH5678",
        "found": true,
        "status": "completed",
        "is_test": true,
        "valid": false,
        "completed_at": "2026-08-20T10:00:00+03:30",
        "completed_at_jalali": "1405/05/29 10:00",
        "signers_count": 1,
        "sealed_at": null,
        "sealed_at_jalali": null,
        "title": "آزمایشی",
        "company_signatures": [],
        "identity_summary": []
    }
}
 

Example response (200, not completed):


{
    "data": {
        "code": "ABCD1234EFGH5678",
        "found": true,
        "status": "waiting_signature",
        "is_test": false,
        "valid": false,
        "completed_at": null,
        "completed_at_jalali": null,
        "signers_count": null,
        "sealed_at": null,
        "sealed_at_jalali": null,
        "title": null,
        "company_signatures": [],
        "identity_summary": []
    }
}
 

Example response (404, unknown code):


{
    "type": "https://docs.elemza.com/errors/not_found",
    "status": 404,
    "code": "not_found",
    "title_fa": "سندی با این کد رهگیری ثبت نشده است",
    "title_en": "No document has this tracking code",
    "request_id": "01J..."
}
 

Example response (429, too many requests):


{
    "type": "https://docs.elemza.com/errors/rate_limit_exceeded",
    "status": 429,
    "code": "rate_limit_exceeded",
    "title_fa": "تعداد درخواست از حد مجاز فراتر رفت",
    "title_en": "Rate limit exceeded",
    "request_id": "01J..."
}
 

Request      

GET api/v1/verify/{code}

Headers

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

code   string     

The document's tracking code. Example: ABCD1234EFGH5678

Webhooks

Outbound webhook subscriptions. Customers create one or more endpoints, each filtered by an array of event names. Deliveries are signed with HMAC-SHA256 via the secret returned at create-time (shown only once).

Scope: webhooks:manage.

List webhook subscriptions

requires authentication

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/webhooks?active=&page=16&per_page=16" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"active\": false,
    \"page\": 16,
    \"per_page\": 22
}"
const url = new URL(
    "https://elemza.com/api/v1/webhooks"
);

const params = {
    "active": "0",
    "page": "16",
    "per_page": "16",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "active": false,
    "page": 16,
    "per_page": 22
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG9AV9ZC2F3Q3D3JBPXMQ
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG9AV9ZC2F3Q3D3JBPXMQ"
}
 

Request      

GET api/v1/webhooks

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

active   boolean  optional    

Filter by active state. Example: false

page   integer  optional    

Example: 16

per_page   integer  optional    

Max 100. Example: 16

Body Parameters

active   boolean  optional    

Example: false

page   integer  optional    

value باید حداقل 1 باشد. Example: 16

per_page   integer  optional    

value باید حداقل 1 باشد. value نباید بیشتر از 100 باشد. Example: 22

Get webhook subscription

requires authentication

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/webhooks/B8c6F7NNfcj9m6RJYC6RtkmZN6" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/webhooks/B8c6F7NNfcj9m6RJYC6RtkmZN6"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG9B17S595X9G04BMPX6D
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG9B17S595X9G04BMPX6D"
}
 

Request      

GET api/v1/webhooks/{id}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   string     

The ID of the webhook. Example: B8c6F7NNfcj9m6RJYC6RtkmZN6

List webhook deliveries

requires authentication

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/webhook-deliveries?subscription_id=architecto&event_name=architecto&status=architecto&page=16&per_page=16" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/webhook-deliveries"
);

const params = {
    "subscription_id": "architecto",
    "event_name": "architecto",
    "status": "architecto",
    "page": "16",
    "per_page": "16",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG9BEZ238YA5TWR04PH6P
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG9BEZ238YA5TWR04PH6P"
}
 

Request      

GET api/v1/webhook-deliveries

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

subscription_id   string  optional    

Filter by subscription. Example: architecto

event_name   string  optional    

Filter by event name. Example: architecto

status   string  optional    

pending|delivered|failed|dead-letter Example: architecto

page   integer  optional    

Example: 16

per_page   integer  optional    

Max 100. Example: 16

Get webhook delivery

requires authentication

Shows full payload, response code, error message, attempt history.

Example request:
curl --request GET \
    --get "https://elemza.com/api/v1/webhook-deliveries/B8c6F7NNfcj9m6RJYC6RtkmZN6" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/webhook-deliveries/B8c6F7NNfcj9m6RJYC6RtkmZN6"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (401):

Show headers
x-request-id: 01M7RWG9BM0SBP422S36W750BD
x-emza-api-version: v1
cache-control: no-cache, private
content-type: application/problem+json
access-control-allow-origin: *
access-control-expose-headers: X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, X-Emza-API-Version, X-Idempotent-Replay
 

{
    "type": "https://docs.elemza.com/errors/token_invalid",
    "status": 401,
    "code": "token_invalid",
    "title_fa": "توکن نامعتبر است",
    "title_en": "Invalid token",
    "request_id": "01M7RWG9BM0SBP422S36W750BD"
}
 

Request      

GET api/v1/webhook-deliveries/{id}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   string     

The ID of the webhook delivery. Example: B8c6F7NNfcj9m6RJYC6RtkmZN6

Create webhook subscription

requires authentication

Registers an HTTPS endpoint to receive event deliveries. We POST each matching event to your URL and sign it with HMAC-SHA256:

X-Emza-Timestamp: <unix seconds>
X-Emza-Signature: sha256=<hex hash_hmac('sha256', "{timestamp}.{raw_body}", secret)>

Compare with hash_equals, and reject anything whose timestamp is more than 5 minutes old.

NOTE: this docblock is published to customers by Scribe. Until 2026-07-31 it described a Stripe-style X-Emza-Signature: t=<unix>,v1=<hex> header that this platform has never sent — see App\Services\Webhook\WebhookSigner, which is the only authority on the wire format, and tests/Feature/Sdk/SdkWebhookVerificationTest, which pins the two together.

The plain signing secret is returned ONCE — store it immediately. Subsequent reads (index, show) omit the secret entirely. Use PATCH /webhooks/{id} with rotate_secret=true to issue a fresh secret (invalidates the previous one immediately).

URL validation (SSRF guard): the url field is rejected with 422 if it fails any of:

Allowed event names (set in events array — use ["*"] for all): contract.created, contract.processing.completed, contract.processing.failed, contract.signer.added, contract.signer.authenticated, contract.signer.signed, contract.signer.rejected, contract.completed, contract.canceled, contract.voided, contract.refunded, form.submission.created, form.submission.completed, form.submission.bridged, form.submission.bridge_failed, certificate.issued, certificate.failed, certificate.expiring, certificate.expired, certificate.revoked, contract.signature.failed, signer.certificate.missing, contract.signing_deadline.passed, contract.amendment.completed, contract.rescinded, plus * (wildcard).

NOTE: this list is typed by hand because Scribe publishes the docblock verbatim and cannot read a constant. It is pinned to ALLOWED_EVENTS by ApiDocsFreshnessTest::test_the_webhook_docblock_lists_exactly_the_allowed_events — until 1405/06/18 it advertised ten of the twenty events and had been half a product behind since the form and certificate workstreams shipped.

If * is present alongside specific events, the specifics are dropped (the wildcard makes them redundant). Same event listed twice is deduped.

Scope: webhooks:manage. Idempotency-Key required (24h replay window).

Example request:
curl --request POST \
    "https://elemza.com/api/v1/webhooks" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"url\": \"https:\\/\\/example.com\\/webhooks\\/emza\",
    \"events\": [
        \"contract.completed\",
        \"contract.signer.signed\"
    ],
    \"active\": false
}"
const url = new URL(
    "https://elemza.com/api/v1/webhooks"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "url": "https:\/\/example.com\/webhooks\/emza",
    "events": [
        "contract.completed",
        "contract.signer.signed"
    ],
    "active": false
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (201):


{
    "data": {
        "id": "01krh7z0e8a4n39gf2ary73xbj",
        "url": "https://example.com/webhooks/emza",
        "events": [
            "contract.completed",
            "contract.signer.signed"
        ],
        "active": true,
        "disabled_at": null,
        "failed_deliveries_count": 0,
        "last_delivery_at": null,
        "last_delivery_status": null,
        "created_at": "2026-05-13T18:00:42.000Z",
        "updated_at": "2026-05-13T18:00:42.000Z",
        "secret": "35ada3b45aa00df901b74b2b483114315a0c21f7c096f17e0bb29ab7d907fe32",
        "_warning": "Save this secret now — it will NOT be shown again."
    }
}
 

Example response (409, URL already subscribed):


{
    "type": "https://docs.elemza.com/errors/subscription_exists",
    "status": 409,
    "code": "subscription_exists",
    "title_fa": "این نشانی از قبل ثبت شده است",
    "title_en": "This URL already has an active subscription",
    "detail_en": "Reuse subscription 01krh7z0e8a4n39gf2ary73xbj, or DELETE it and create a new one. If you lost its signing secret, call PATCH /webhooks/01krh7z0e8a4n39gf2ary73xbj with rotate_secret=true.",
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS",
    "meta": {
        "subscription_id": "01krh7z0e8a4n39gf2ary73xbj",
        "url": "https://example.com/webhooks/emza",
        "events": [
            "contract.completed"
        ],
        "created_at": "2026-05-13T18:00:42.000Z"
    }
}
 

Example response (422, SSRF blocked URL):


{
    "type": "https://docs.elemza.com/errors/validation",
    "status": 422,
    "code": "validation",
    "title_fa": "اعتبارسنجی ورودی شکست خورد",
    "title_en": "Request validation failed",
    "errors": {
        "url": [
            "آدرس‌های داخلی شبکه (localhost / *.local / *.internal) مجاز نیستند."
        ]
    },
    "request_id": "01KRH8JRC4Y855P10CYC1C0AYS"
}
 

Request      

POST api/v1/webhooks

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

url   string     

HTTPS endpoint to receive deliveries. Max 500 chars. Example: https://example.com/webhooks/emza

events   string[]     

Event names from the allowed list. Use ["*"] for all.

active   boolean  optional    

When false, subscription is paused (no deliveries). Default true. Example: false

Update webhook subscription

requires authentication

Partial update — any field omitted is left unchanged. New url values pass through the same SSRF guard as POST /webhooks (see Create endpoint).

When rotate_secret=true, a fresh HMAC signing secret is generated and returned in the response — the previous secret is invalidated immediately, so any in-flight or already-sent webhook deliveries signed with the old secret will fail verification on the receiver side. Plan rotations during a quiet period or pause via active=false first.

Scope: webhooks:manage. Idempotency-Key required (24h replay window).

Example request:
curl --request PATCH \
    "https://elemza.com/api/v1/webhooks/01krh7z0e8a4n39gf2ary73xbj" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"url\": \"http:\\/\\/www.bailey.biz\\/quos-velit-et-fugiat-sunt-nihil-accusantium-harum.html\",
    \"events\": [
        \"architecto\"
    ],
    \"active\": false,
    \"rotate_secret\": false
}"
const url = new URL(
    "https://elemza.com/api/v1/webhooks/01krh7z0e8a4n39gf2ary73xbj"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "url": "http:\/\/www.bailey.biz\/quos-velit-et-fugiat-sunt-nihil-accusantium-harum.html",
    "events": [
        "architecto"
    ],
    "active": false,
    "rotate_secret": false
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200):


{
    "data": {
        "id": "01krh7z0e8a4n39gf2ary73xbj",
        "url": "https://example.com/webhooks/emza",
        "events": [
            "*"
        ],
        "active": false,
        "failed_deliveries_count": 2,
        "last_delivery_at": "2026-05-13T17:30:00.000Z",
        "last_delivery_status": "delivered"
    }
}
 

Request      

PATCH api/v1/webhooks/{id}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   string     

Webhook subscription ULID. Example: 01krh7z0e8a4n39gf2ary73xbj

Body Parameters

url   string  optional    

New endpoint URL (subject to same SSRF guard as create). Example: http://www.bailey.biz/quos-velit-et-fugiat-sunt-nihil-accusantium-harum.html

events   string[]  optional    

Replaces the entire events list. Same allowed values as create.

active   boolean  optional    

Toggle the subscription on/off without deleting it. Example: false

rotate_secret   boolean  optional    

When true, issues a fresh secret (returned in response under secret + _warning). Example: false

Delete webhook subscription

requires authentication

Soft-deletes the subscription. In-flight deliveries that have already been queued will complete; no new deliveries are dispatched.

Example request:
curl --request DELETE \
    "https://elemza.com/api/v1/webhooks/B8c6F7NNfcj9m6RJYC6RtkmZN6" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/webhooks/B8c6F7NNfcj9m6RJYC6RtkmZN6"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());

Request      

DELETE api/v1/webhooks/{id}

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   string     

The ID of the webhook. Example: B8c6F7NNfcj9m6RJYC6RtkmZN6

Send a synthetic test event

requires authentication

Fires a webhook.test event to verify the endpoint is reachable + signed correctly. Counts toward webhook_deliveries like a real event.

Example request:
curl --request POST \
    "https://elemza.com/api/v1/webhooks/B8c6F7NNfcj9m6RJYC6RtkmZN6/test" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/webhooks/B8c6F7NNfcj9m6RJYC6RtkmZN6/test"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Request      

POST api/v1/webhooks/{id}/test

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   string     

The ID of the webhook. Example: B8c6F7NNfcj9m6RJYC6RtkmZN6

Replay webhook delivery

requires authentication

Creates a NEW delivery row with the same payload + subscription. The original row keeps its terminal status (failed / dead-letter / delivered).

Example request:
curl --request POST \
    "https://elemza.com/api/v1/webhook-deliveries/B8c6F7NNfcj9m6RJYC6RtkmZN6/replay" \
    --header "Authorization: Bearer 42|abcdef1234567890abcdef1234567890abcdef" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://elemza.com/api/v1/webhook-deliveries/B8c6F7NNfcj9m6RJYC6RtkmZN6/replay"
);

const headers = {
    "Authorization": "Bearer 42|abcdef1234567890abcdef1234567890abcdef",
    "Content-Type": "application/json",
    "Accept": "application/json",
};


fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());

Request      

POST api/v1/webhook-deliveries/{id}/replay

Headers

Authorization        

Example: Bearer 42|abcdef1234567890abcdef1234567890abcdef

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   string     

The ID of the webhook delivery. Example: B8c6F7NNfcj9m6RJYC6RtkmZN6