Send approvals to e-Sign
e-Sign collects approvals inside Microsoft Teams and keeps a tamper-evident record of who
approved what, and when. Your system sends the request; approvers decide in Teams with their own
Microsoft login; your system reads back approved: true or false.
| Base URL (sandbox) | https://esign-sandbox.mayshowa.my/api/v1 |
|---|---|
| Format | JSON over HTTPS, UTF-8 |
| Times | ISO 8601 with a timezone, for example 2026-10-06T18:00:00+08:00. Responses are in UTC (Z). |
| Contact | AI Department (Mazu) for an API key and help |
Keep the base URL in your configuration file, never in code. It changes when e-Sign moves from sandbox to production.
How it flows
Your system e-Sign Approver (Teams)
─────────── ────── ────────────────
user submits a form
status = Pending
│ POST /approvals ───────────► checks the payload, finds the
│ (payload + hash + approvers) approvers in Microsoft 365
│ ◄─────────── 201 { request_id }
│ │ shows in the Approvals tab ──► reviews,
│ │ approves / rejects /
│ │ ◄─────────────────────────────── acknowledges
│ │ records who, what, when
│ GET /approvals/{request_id} ──► │
│ ◄─────────── { status, approved, decisions[] }
update your record:
Approved / Rejected
e-Sign pushes every decision to your system as a signed callback (see
Callbacks). Polling GET /approvals/{id} stays available as the
safety net (a slow poll, for example every 6 hours, catches anything a callback could not deliver).
Access: your API key
Each calling system gets its own key from the AI Department, one per environment (sandbox, production). It is shown once. Send it on every request:
Authorization: Bearer esk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- Store it in your environment file or secret store. Never in source code, logs or chat.
- A wrong or revoked key returns
401 {"error":"invalid_caller_key"}. - Your key only sees the requests your system created.
- Approvers must have an address on the domains allowed for your system (by default
mayshowa.com,mayshowa.my,mayshowa.com.my).
Send a request Available
POST /api/v1/approvals
Fields
| Field | Required | Meaning |
|---|---|---|
external_request_id | yes | Your own reference, up to 200 characters, for example GDF-B-2026-014. Unique per system. Sending the same one again is safe; see Retries. |
subject_kind | yes | Always "approval-request". |
title | yes | What the approver sees in their inbox, up to 500 characters. |
payload | yes | A JSON object with exactly what the approver needs to decide. Shown to the approver and stored as the record of what was approved. |
payload_media_type | yes | Always "application/json". |
payload_schema | yes | Name and version of your payload layout, for example mayshowa.gift-declaration/1.0. Change the version when the layout changes. |
payload_hash | yes | sha256: plus the hex SHA-256 of the canonical payload. See Payload hash. |
consent_text_version | yes | Which attestation sentence the approver confirms. Ask the AI Department for yours. Available today: gift-attestation/2026-09. |
steps | yes | Who decides. Exactly one step today. See Approvers. |
requester | yes | {"upn": "...", "display_name": "..."}, the person who raised it. The requester can never be an approver of their own request. |
expires_at | no | Deadline with a timezone. After it, the request reads approved: false, reason: "expired". |
callback_url | no | Deprecated and ignored. Callbacks always go to the URL registered for your app (see Callbacks), so a stolen API key cannot redirect decisions. Accepted only so older clients keep working. |
Example
POST /api/v1/approvals
Authorization: Bearer $ESIGN_API_KEY
Content-Type: application/json
{
"external_request_id": "GDF-B-2026-014",
"subject_kind": "approval-request",
"title": "Gift declaration GDF-B-2026-014: sponsored trip from Supplier Y, RM 3,500",
"payload": {
"reference": "GDF-B-2026-014",
"form": "B",
"declarant": { "name": "Aisyah Rahman", "designation": "Sales Executive", "department": "Sales" },
"gift": { "status": "Pending", "type": "Travel", "estimated_value_myr": 3500,
"description": "Product launch trip to Bangkok", "date": "2026-10-20" },
"giver": { "name": "Supplier Y", "organisation": "Supplier Y Co. Ltd",
"relationship": "Prospective supplier", "live_tender_or_contract": true },
"justification": { "text": "Launch includes technical training for our product line." },
"policy_version": "ABC-2026-01"
},
"payload_media_type": "application/json",
"payload_schema": "mayshowa.gift-declaration/1.0",
"payload_hash": "sha256:<computed, see below>",
"consent_text_version": "gift-attestation/2026-09",
"steps": [
{ "order": 1, "role": "exco", "mode": "group-any", "action": "approve",
"group": { "display_name": "EXCO approvers",
"entra_group_id": "<EXCO security group object id>" } }
],
"requester": { "upn": "aisyah.rahman@mayshowa.com", "display_name": "Aisyah Rahman" },
"expires_at": "2026-10-15T18:00:00+08:00"
}
Response
201 Created
{
"request_id": "6e137aa2-742d-45fa-b43a-aa4689f65efc",
"status": "pending",
"steps": [ { "order": 1, "role": "exco", "mode": "group-any", "action": "approve",
"status": "pending", "member_count": 4,
"group": { "display_name": "EXCO approvers", "entra_group_id": "…", "member_count": 4 } } ]
}
Save request_id against your record. You need it to read the decision.
Retries
- If your call times out, send the same request again with the same
external_request_id. You get200and the existing request, never a duplicate. - Same id with a different payload returns
409 external_request_id_reused. A changed declaration is a new request with a new id, for exampleGDF-B-2026-014/v2.
Choosing the approvers
Each step names who decides and what they do.
| Setting | Values | Meaning |
|---|---|---|
mode | single | One named person: "approver": {"upn": "ei.officer@mayshowa.com"}. Only they can decide. |
group-any | A group. Every member sees it; the first member to decide closes it for everyone, and it disappears from the others' inbox. | |
action | approve (default) | The approver chooses Approve or Reject. Reject needs a reason. |
acknowledge | The approver can only acknowledge (for example Form A to the E&I Officer). It counts as approved. | |
role | free text | Your label, for example ei-officer or exco. Shown in the record. |
Two ways to give a group
"group": { "display_name": "EXCO approvers", "entra_group_id": "<object id>" } // preferred
"group": { "display_name": "EXCO approvers",
"members": ["member.one@mayshowa.com", "member.two@mayshowa.com"] }
- Entra group (preferred): membership is managed in Microsoft 365. Members are captured when the request is created; someone removed from the group before deciding can no longer decide. Someone added later is not an approver of requests already sent.
- List of members: useful before a group exists. Up to 50 people.
- Keep approver addresses and group ids in configuration, not in code.
Payload hash
The hash proves which exact version of the declaration was approved. e-Sign recomputes it and refuses the
request (422 payload_hash_mismatch) if yours differs, so nothing is created from a garbled payload.
- Serialise the payload with JSON Canonicalization Scheme (RFC 8785): keys sorted, no spaces, standard number and string encoding.
- SHA-256 the UTF-8 bytes; lowercase hex.
- Send
"sha256:" + hex.
Python
pip install rfc8785
import hashlib, rfc8785
payload_hash = "sha256:" + hashlib.sha256(rfc8785.dumps(payload)).hexdigest()
Node.js
npm install canonicalize
const canonicalize = require("canonicalize");
const crypto = require("crypto");
const payloadHash = "sha256:" + crypto.createHash("sha256").update(canonicalize(payload), "utf8").digest("hex");
Other languages
Use any RFC 8785 (JSON Canonicalization Scheme) library, then SHA-256. Check your code against the test vector below before sending real requests.
Test vector
payload {"reference": "GDF-A-TEST-001", "form": "A",
"gift": {"type": "Hamper", "estimated_value_myr": 450, "status": "Received"},
"declarant": {"name": "Test User"}}
canonical {"declarant":{"name":"Test User"},"form":"A","gift":{"estimated_value_myr":450,"status":"Received","type":"Hamper"},"reference":"GDF-A-TEST-001"}
hash sha256:726e9ed8b5861ecd4ba8d1cb1be6bc970814a23c7a2f048584fc3eef69e5e7ef
- Use whole numbers or plain decimals for money (
3500or3500.5). Avoid very large numbers and duplicate keys; they return422 payload_not_canonicalizable. - Photos and files: send their SHA-256 hash in the payload, never the file itself.
Read the decision Available
GET /api/v1/approvals/{request_id} with your key.
200 OK
{
"request_id": "6e137aa2-742d-45fa-b43a-aa4689f65efc",
"external_request_id": "GDF-B-2026-014",
"status": "approved",
"approved": true,
"reason": "Training value justified",
"payload_hash": "sha256:b0d82d08…",
"decisions": [
{ "order": 1, "role": "exco", "mode": "group-any", "action": "approve",
"by": { "oid": "f1d80910-…", "upn": "exco.member@mayshowa.com", "display_name": "Exco Member" },
"result": "approved", "reason": "Training value justified",
"at": "2026-10-02T06:40:10Z", "ledger_ordinal": 1203,
"group": { "display_name": "EXCO approvers", "entra_group_id": "…" } }
],
"steps": [ { "order": 1, "status": "approved", "mode": "group-any", "member_count": 4, "…": "…" } ],
"ledger_head": "sha256:40dd3440…"
}
What to store on your side
| Store | From |
|---|---|
| Outcome | approved (true, false, or null while pending) and status |
| Decided by | decisions[].by.display_name and upn; oid is the permanent Microsoft id |
| Decided at | decisions[].at |
| Reason | reason |
| Proof | request_id and payload_hash; auditors use them to find the full record |
Polling
Check pending requests every 1 to 5 minutes, and stop once status is not pending.
A decision never changes after it is recorded.
Full history Available
GET /api/v1/approvals/{request_id}/history returns every recorded event for your request in order:
requested, viewed, approved and so on, each with its time and the audit chain hashes.
{ "request_id": "…", "external_request_id": "GDF-B-2026-014", "subject_kind": "approval-request",
"events": [
{ "ordinal": 1187, "action": "viewed", "result": "ok", "step_order": 1,
"actor": { "oid": "…", "upn": "exco.member@mayshowa.com", "display_name": "Exco Member" },
"actor_redacted": false, "at": "2026-10-02T06:39:02Z",
"payload_hash": "sha256:…", "hash": "sha256:…", "prev_hash": "sha256:…" } ] }
If someone who is not an approver tries to open your request, the attempt appears as a
refused event with actor_redacted: true and no name. The full record stays with the auditor.
Statuses and what to do
status | approved | Meaning | Your system |
|---|---|---|---|
pending | null | Waiting for a decision | Keep polling |
approved | true | Approved or acknowledged | Mark approved |
rejected | false | Rejected; reason says why | Mark rejected, show the reason |
expired | false | Nobody decided before expires_at | Flag overdue; send a new request if still needed |
Errors
Every error is JSON: {"error": "<code>", …details}. Nothing is created when a request is refused.
| HTTP | Code | Fix |
|---|---|---|
| 401 | invalid_caller_key | Check the key in your configuration |
| 404 | not_found | Wrong id, or a request created by another system |
| 409 | external_request_id_reused | Same id, different payload: use a new id |
| 422 | payload_hash_mismatch | Recompute the hash with RFC 8785 (see above) |
| 422 | payload_not_canonicalizable, payload_hash_malformed | Fix the payload or the sha256: format |
| 422 | approver_not_found | The address is not in Microsoft 365 |
| 422 | approver_not_allowed | The approver's domain is not allowed for your system |
| 422 | separation_of_duties | The requester is also an approver; pick someone else |
| 422 | group_not_found, group_empty, group_too_large, entra_group_id_malformed, group_members_malformed | Check the group id or member list (max 50) |
| 422 | invalid_step_mode, invalid_step_action, invalid_step_order, steps_required, multi_step_not_supported_yet | Check steps: one step, order: 1 |
| 422 | unknown_consent_text_version | Use a version the AI Department gave you |
| 422 | expires_at_in_past, expires_at_needs_timezone | Send a future time with +08:00 or Z |
| 422 | subject_kind_not_supported, payload_media_type_not_supported | Use the fixed values above |
| 503 | directory_unavailable | Microsoft 365 is unreachable; retry later with the same id |
Callbacks Available
e-Sign pushes every decision to your app's registered callback URL: the AI Department
registers it together with your API key, one registration per environment (sandbox and production are
separate). The URL must be https on a public address. You receive a key file with two values,
key_id= and secret=; put both in your configuration (never in source or logs). The
callback secret is not your API key.
POST <your registered callback URL>
Content-Type: application/json
X-ESign-Delivery: <uuid> the same on every retry of this delivery
X-ESign-Timestamp: <unix seconds> fresh on every attempt
X-ESign-Key-Id: <key id>
X-ESign-Signature: v1=<hex HMAC-SHA256(secret, "v1." + timestamp + "." + delivery + "." + raw body)>
body: the same object as GET /approvals/{id} at that moment, plus
"schema": "esign.callback/1"
"event": "step.decided" | "request.approved" | "request.rejected" | "request.expired"
"event_at": when it happened (UTC)
"event_seq": 1, 2, 3 … per request, in the order the events happened
The HMAC key is the secret's exact text as UTF-8 bytes. The last decision of a request sends two events, in
order: step.decided then request.approved (or request.rejected). A request
that passes its expires_at sends request.expired.
- Verify the signature over the raw body bytes before parsing. Reject timestamps older than 5 minutes or more than 1 minute in the future.
- Delivery is at-least-once: ignore a
X-ESign-Deliveryyou already processed, and still answer 200. - Events of one request are sent in
event_seqorder, but still tolerate them out of order (useevent_seqand the status in the body; never step a record backwards). - Answer 2xx within 10 seconds, then do slow work. Redirects are not followed. Anything else is retried after about 1 min, 5 min, 15 min, 1 h, then every 6 h, for 72 hours; then the delivery is parked and the AI Department can resend it. Polling always works as the fallback.
- Key rotation never rejects a delivery if you follow the order: the AI Department sends you the NEW key file; you configure BOTH key ids (current + previous) and restart; e-Sign then signs with the new key; once it confirms the old key is revoked, remove it from your configuration.
Integration checklist
- Get a sandbox API key from the AI Department; put it and the base URL in your environment file.
- Build the payload from your form: only what the approver needs, no photos, no IDs they do not need.
- Compute the RFC 8785 hash and send
POST /approvals; saverequest_id. - Give the AI Department your callback URL; store the key file's
key_idandsecretin configuration. - Keep your record Pending until a verified callback (or a slow safety-net poll of
GET /approvals/{id}) says otherwise. - Store outcome, decided by, decided at, reason,
request_idandpayload_hash. - Handle every status and every error in the tables above; retry timeouts with the same id.
- Test with the AI Department in the sandbox, then ask for a production key.