Mayshowa e-Sign Integration guide Sandbox · API v1

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.

Your system never builds an approval screen. It asks the question, stores the answer, and shows the result. e-Sign handles the approvers, their identity and the audit record.
Base URL (sandbox)https://esign-sandbox.mayshowa.my/api/v1
FormatJSON over HTTPS, UTF-8
TimesISO 8601 with a timezone, for example 2026-10-06T18:00:00+08:00. Responses are in UTC (Z).
ContactAI 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

Send a request Available

POST /api/v1/approvals

Fields

FieldRequiredMeaning
external_request_idyesYour 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_kindyesAlways "approval-request".
titleyesWhat the approver sees in their inbox, up to 500 characters.
payloadyesA 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_typeyesAlways "application/json".
payload_schemayesName and version of your payload layout, for example mayshowa.gift-declaration/1.0. Change the version when the layout changes.
payload_hashyessha256: plus the hex SHA-256 of the canonical payload. See Payload hash.
consent_text_versionyesWhich attestation sentence the approver confirms. Ask the AI Department for yours. Available today: gift-attestation/2026-09.
stepsyesWho decides. Exactly one step today. See Approvers.
requesteryes{"upn": "...", "display_name": "..."}, the person who raised it. The requester can never be an approver of their own request.
expires_atnoDeadline with a timezone. After it, the request reads approved: false, reason: "expired".
callback_urlnoDeprecated 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

Choosing the approvers

Each step names who decides and what they do.

SettingValuesMeaning
modesingleOne named person: "approver": {"upn": "ei.officer@mayshowa.com"}. Only they can decide.
group-anyA group. Every member sees it; the first member to decide closes it for everyone, and it disappears from the others' inbox.
actionapprove (default)The approver chooses Approve or Reject. Reject needs a reason.
acknowledgeThe approver can only acknowledge (for example Form A to the E&I Officer). It counts as approved.
rolefree textYour 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"] }
One step per request today. Two steps in sequence (for example E&I Officer, then EXCO) are being built. Until then, send the second step as a separate request after the first is approved.

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.

  1. Serialise the payload with JSON Canonicalization Scheme (RFC 8785): keys sorted, no spaces, standard number and string encoding.
  2. SHA-256 the UTF-8 bytes; lowercase hex.
  3. 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

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

StoreFrom
Outcomeapproved (true, false, or null while pending) and status
Decided bydecisions[].by.display_name and upn; oid is the permanent Microsoft id
Decided atdecisions[].at
Reasonreason
Proofrequest_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

statusapprovedMeaningYour system
pendingnullWaiting for a decisionKeep polling
approvedtrueApproved or acknowledgedMark approved
rejectedfalseRejected; reason says whyMark rejected, show the reason
expiredfalseNobody decided before expires_atFlag overdue; send a new request if still needed

Errors

Every error is JSON: {"error": "<code>", …details}. Nothing is created when a request is refused.

HTTPCodeFix
401invalid_caller_keyCheck the key in your configuration
404not_foundWrong id, or a request created by another system
409external_request_id_reusedSame id, different payload: use a new id
422payload_hash_mismatchRecompute the hash with RFC 8785 (see above)
422payload_not_canonicalizable, payload_hash_malformedFix the payload or the sha256: format
422approver_not_foundThe address is not in Microsoft 365
422approver_not_allowedThe approver's domain is not allowed for your system
422separation_of_dutiesThe requester is also an approver; pick someone else
422group_not_found, group_empty, group_too_large, entra_group_id_malformed, group_members_malformedCheck the group id or member list (max 50)
422invalid_step_mode, invalid_step_action, invalid_step_order, steps_required, multi_step_not_supported_yetCheck steps: one step, order: 1
422unknown_consent_text_versionUse a version the AI Department gave you
422expires_at_in_past, expires_at_needs_timezoneSend a future time with +08:00 or Z
422subject_kind_not_supported, payload_media_type_not_supportedUse the fixed values above
503directory_unavailableMicrosoft 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.

Integration checklist

  1. Get a sandbox API key from the AI Department; put it and the base URL in your environment file.
  2. Build the payload from your form: only what the approver needs, no photos, no IDs they do not need.
  3. Compute the RFC 8785 hash and send POST /approvals; save request_id.
  4. Give the AI Department your callback URL; store the key file's key_id and secret in configuration.
  5. Keep your record Pending until a verified callback (or a slow safety-net poll of GET /approvals/{id}) says otherwise.
  6. Store outcome, decided by, decided at, reason, request_id and payload_hash.
  7. Handle every status and every error in the tables above; retry timeouts with the same id.
  8. Test with the AI Department in the sandbox, then ask for a production key.