API reference

Agent setup

Common headers

Every endpoint on this page takes these headers.

NameDescription
MonetizePay-Accountheader, string or null

Optional. The merchant (mch_...) this request acts on, when the body has no merchant_id: the analogue of Stripe's Stripe-Account header.

Stripe-Accountheader, string or null

Optional. A synonym of MonetizePay-Account; holds a merchant id (mch_...).

Common responses

Every endpoint on this page can answer with these.

StatusDescriptionBody
400

Invalid request. A parameter, header or body field failed validation (code parameter_invalid, with param naming it), or another invalid_request code this operation's description lists. Fix the request; do not retry it unchanged.

ErrorResponse
404

No such resource for this platform (resource_missing), or another not_found code this operation's description lists.

ErrorResponse
413

The request body is over 1048576 bytes, or its Content-Length is not a number (code payload_too_large). Every write method is checked, before routing. A body sent without a Content-Length (chunked) is accepted on /v1 and counted as it arrives; elsewhere it is refused. The connection is closed after this answer. Send a smaller body.

ErrorResponse
429

Too many requests (rate_limited). Wait for the Retry-After header, then retry.

ErrorResponse

Start agent setup

POST/v1/agent_setup

Emails a 6-digit code to the address. No API key needed. The answer is the same for every valid address.

Next step: ask the person for the code (or read it from their inbox), then call POST /v1/agent_setup/{id}/verify. No code within 2 minutes? An address that already has an account gets a sign-in link instead, not a code; otherwise ask the person to contact Monetize.Pay support.

Errors: terms_outdated, email_invalid, email_domain_blocked (400); not_found when self-serve is paused (404); rate_limited (429); email_unavailable (503).

Parameters

Request body

FieldDescription
emailstringRequired

The builder's email address. The 6-digit code is sent there.

termsstringRequired

The sha256 of the current Terms of Service text, as agent-setup.md gives it. Sending the code back accepts those Terms.

Responses

StatusDescriptionBody
202

Successful Response

AgentSetupOut
503

No processor is available for this merchant or deployment (processor_not_connected, sandbox_processor_unconfigured, connect_unavailable).

ErrorResponse

Example

curl
curl -X POST "https://api.monetize.pay/v1/agent_setup" \
  -H "Content-Type: application/json" \
  -d '{
    "email": <email>,
    "terms": <terms>
  }'
Python
import requests

response = requests.post(
    "https://api.monetize.pay/v1/agent_setup",
    json={
        "email": "<email>",
        "terms": "<terms>",
    },
)
print(response.json())
Node.js
const response = await fetch("https://api.monetize.pay/v1/agent_setup", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "email": "<email>",
    "terms": "<terms>",
  }),
});
console.log(await response.json());

Verify the agent setup code

POST/v1/agent_setup/{setup_id}/verify

Sends the emailed code back. No API key needed. On a match, answers a test API key with the self-serve scopes, shown in this response only; the Terms of Service are accepted. Every failure is code_invalid (400) with attempts_left: after 10 minutes or 5 wrong tries the code is dead, so start again with POST /v1/agent_setup. Other errors: rate_limited (429); signup_limit_exceeded (429, the correct code while the day's sandbox sign-ups are full: the code is not spent; Retry-After counts to 00:00 UTC); terms_unrecordable (503, try again shortly).

Next step: call GET /v1/me with the key, or connect the MCP server at mcp_url. When other_test_keys is not empty, ask the person whether they made those keys; if not, end them with POST /v1/agent_setup/{setup_id}/end_other_keys.

Parameters

NameDescription
setup_idpath, stringRequired

Request body

FieldDescription
codestringRequired

The 6-digit code from the email. Spaces and dashes are ignored.

Responses

StatusDescriptionBody
200

Successful Response

AgentSetupKeyOut
503

No processor is available for this merchant or deployment (processor_not_connected, sandbox_processor_unconfigured, connect_unavailable).

ErrorResponse

Example

curl
curl -X POST "https://api.monetize.pay/v1/agent_setup/{setup_id}/verify" \
  -H "Content-Type: application/json" \
  -d '{
    "code": <code>
  }'
Python
import requests

response = requests.post(
    "https://api.monetize.pay/v1/agent_setup/{setup_id}/verify",
    json={
        "code": "<code>",
    },
)
print(response.json())
Node.js
const response = await fetch("https://api.monetize.pay/v1/agent_setup/{setup_id}/verify", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "code": "<code>",
  }),
});
console.log(await response.json());

End the other test keys after an agent recovery

POST/v1/agent_setup/{setup_id}/end_other_keys

Ends every other active test key of the sandbox an agent recovery just served. Send the key that recovery issued as the Bearer, within 15 minutes of the recovery. No other key can call this, and only the sandbox's newest recovery can. When it ends a key, it also pauses the sandbox's test webhook endpoints. Live keys and live endpoints are never touched. Calling it again changes nothing more.

Errors: recovery_key_required (403) for any other key, setup id or time.

Parameters

NameDescription
setup_idpath, stringRequired

Responses

StatusDescriptionBody
200

Successful Response

AgentSetupEndOut
401

The API key is missing, malformed, unknown or revoked (api_key_missing, api_key_malformed, api_key_invalid). Fix the Authorization header.

ErrorResponse
403

The key is valid but may not do this: platform_suspended, insufficient_scope, live_mode_unavailable, or a permission code this operation's description lists (for example processor_currency_unsupported).

ErrorResponse

Example

curl
curl -X POST "https://api.monetize.pay/v1/agent_setup/{setup_id}/end_other_keys" \
  -H "Authorization: Bearer zp_test_..."
Python
import requests

response = requests.post(
    "https://api.monetize.pay/v1/agent_setup/{setup_id}/end_other_keys",
    headers={
        "Authorization": "Bearer zp_test_...",
    },
)
print(response.json())
Node.js
const response = await fetch("https://api.monetize.pay/v1/agent_setup/{setup_id}/end_other_keys", {
  method: "POST",
  headers: {
    "Authorization": "Bearer zp_test_...",
  },
});
console.log(await response.json());