Skip to content

Attach a document to a business account request ​

Uploads one document to a business account request that is a draft or was declined. One call takes one file. Documents cannot be replaced or removed through the API: send the right file the first time.

Endpoint ​

POST /v1/payments/merchant/accounts/{id}/org-requests/{request_id}/documents
AuthSecret key
Scopeaccounts:write
PlatformYour organisation must be switched on as a platform, and the call must come from an allowed address if MOOKHPay set a list
Switched onWith the platform API on that deployment

The key is checked with authn on every call, with no 60-second cache.

Headers ​

HeaderRequiredValue
AuthorizationYesBearer mkp_…
Content-TypeYesmultipart/form-data with its boundary. Your HTTP library sets it when you send form data

No Idempotency-Key. A retry after a lost answer attaches the file again; read the request first to see whether documents already holds it.

Parameters ​

Path

NameTypeRequiredConstraints
idstringYesThe seller's account id
request_idstringYesorq_ and 24 hex characters, a request of this account

Body: multipart/form-data with exactly two fields, each once. Any other field, a field sent twice, a missing field, or another content type is refused.

FieldTypeRequiredConstraints
typetextYesregistration_certificate, incorporation_certificate, tax_pin or cr12, and one the request's kind needs: registration_certificate and tax_pin for sole_prop; incorporation_certificate, tax_pin and cr12 for company
filefileYesOne PDF, JPEG or PNG, not empty, at most 10 MB. The part's own content type must be application/pdf, image/jpeg or image/png, and must match what the bytes are: a PNG labelled application/pdf is refused

A request holds at most 10 documents.

Example request ​

sh
curl -X POST https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/org-requests/orq_3c8e1a9f4b7d20e6c5a1b902/documents \
  -H "Authorization: Bearer $MOOKHPAY_SECRET_KEY" \
  -F "type=registration_certificate" \
  -F "[email protected];type=application/pdf"
js
import { readFile } from "node:fs/promises";

const account = "acct_ke_9c2f41b07e5d38a6c1f0b294";
const requestId = "orq_3c8e1a9f4b7d20e6c5a1b902";

const form = new FormData();
form.append("type", "registration_certificate");
form.append(
  "file",
  new Blob([await readFile("registration-certificate.pdf")], { type: "application/pdf" }),
  "registration-certificate.pdf",
);

const res = await fetch(
  `https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/${account}/org-requests/${requestId}/documents`,
  {
    method: "POST",
    headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
    body: form,
  },
);
const answer = await res.json();
if (!answer.ok) throw new Error(`${res.status} ${answer.code}: ${answer.description}`);
console.log(answer.data.document.id);
python
import os

import requests

account = "acct_ke_9c2f41b07e5d38a6c1f0b294"
request_id = "orq_3c8e1a9f4b7d20e6c5a1b902"

with open("registration-certificate.pdf", "rb") as f:
    res = requests.post(
        f"https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/{account}"
        f"/org-requests/{request_id}/documents",
        headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
        data={"type": "registration_certificate"},
        files={"file": ("registration-certificate.pdf", f, "application/pdf")},
        timeout=60,
    )
answer = res.json()
if not answer["ok"]:
    raise RuntimeError(f"{res.status_code} {answer['code']}: {answer['description']} {answer['data']}")
print(answer["data"]["document"]["id"])
php
<?php
$account = 'acct_ke_9c2f41b07e5d38a6c1f0b294';
$requestId = 'orq_3c8e1a9f4b7d20e6c5a1b902';

$ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/{$account}/org-requests/{$requestId}/documents");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'type' => 'registration_certificate',
        'file' => new CURLFile('registration-certificate.pdf', 'application/pdf', 'registration-certificate.pdf'),
    ],
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('MOOKHPAY_SECRET_KEY')],
]);
$answer = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (!$answer['ok']) {
    throw new RuntimeException("{$status} {$answer['code']}: {$answer['description']}");
}
echo $answer['data']['document']['id'], PHP_EOL;

Do not set Content-Type yourself in Node, Python or PHP: the library writes it with the boundary. In curl, ;type=application/pdf sets the file part's content type; without it curl guesses from the file name.

Response ​

201 Created with description Document attached.

json
{
  "ok": true,
  "description": "Document attached",
  "data": {
    "document": {
      "id": "orqd_7a1c3e5f9b2d4068e1a3c5b7",
      "type": "registration_certificate",
      "file_name": "registration-certificate.pdf",
      "content_type": "application/pdf",
      "size": 284113,
      "uploaded_at": "2026-11-20T09:04:12.000Z"
    }
  }
}

Response fields ​

FieldTypeMeaning
document.idstringThe document's id
document.typestringThe type you sent, in lower case
document.file_namestringThe file name you sent, up to 255 characters, or document if there was none
document.content_typestringapplication/pdf, image/jpeg or image/png
document.sizeintegerBytes
document.uploaded_atstringISO 8601, UTC

The file itself is never returned. Documents are private and only MOOKHPay staff and the seller can open them.

Errors ​

HTTPCodeNameWhenWhat to do
4001701INVALID_REQUEST_DATAThe body is not multipart/form-data, or does not have exactly the fields type and file once eachSend the two fields and nothing else
4003014IDENTITY_HEADER_REFUSEDThe request carries a session or identity headerRemove it
4003034ORG_REQUEST_DOCUMENT_REJECTEDThe file was not taken. data.reason says why: type (an unknown type, or a file that is not a PDF, JPEG or PNG, or whose bytes do not match its content type), not_for_this_kind (a type this kind does not need), empty, missing, unreadable or too_many (the request already has 10)Fix the file or the type
4012781API_KEY_INVALIDMissing, malformed, unknown or revoked keyCheck the key
4032941API_KEY_SCOPE_REQUIREDThe key lacks accounts:writeIssue a key with the scope
4033042API_KEY_IP_NOT_ALLOWEDThe account has allowed addresses and the call came from another addressCall from a listed address
4032942PLATFORM_NOT_ENABLEDYour organisation is not a platform, or its platform is suspendedTalk to MOOKHPay
4033013PLATFORM_IP_NOT_ALLOWEDThe call came from an address not on your platform's allow-listCall from a listed address
4042943PLATFORM_ACCOUNT_NOT_FOUNDThe account is unknown, another platform's, revoked or malformedCheck the id
4043028ORG_REQUEST_NOT_FOUNDThe request is unknown, malformed, or not this account'sCheck request_id
4093033ORG_REQUEST_WRONG_STATEThe request is not a draft or declined: it was sent, approved or withdrawnDocuments can be added only before sending, or after a decline
4131701INVALID_REQUEST_DATAThe whole body is over about 10.06 MBSend a smaller file
4133034ORG_REQUEST_DOCUMENT_REJECTEDThe file is over 10 MB. data.reason is sizeSend a smaller file
4291804RATE_LIMIT_EXCEEDEDOver the rate limit, or your platform reached its limit of unknown account idsWait Retry-After seconds
5032782AUTHN_UNAVAILABLEThe key could not be checkedRetry
5033016PLATFORM_ACCOUNTS_UNAVAILABLEThe document could not be storedRead the request, then retry if the document is not there

Rate limit ​

120 requests a minute, shared by every account, balance, transaction, payout read, account link and business account request route your platform calls. Over it: 429, code 1804, with Retry-After and data.retryAfter in seconds.

Staging documentation. A checkout made with a secret key on staging charges a real phone. See Environments.