API reference

Errors

A refused call returns a 4xx status and one JSON shape.

Shape

{
  "error": {
    "code": "not_found",
    "message": "This Passport link is not active. Ask the renter for a new one."
  }
}
Field Type Description
error.code string Stable and machine readable. Branch on this.
error.message string Plain words for a person. May change. Do not parse it.

Every response carries Content-Type: application/json; charset=utf-8 and Cache-Control: no-store. A 401 also carries WWW-Authenticate: Bearer.

Codes

Checks run in this order. The first one that fails answers.

Status Code Message What to do
401 unauthorized Send your key as: Authorization: Bearer rpk_live_... No key, or not shaped like one. Check the header.
401 unauthorized This key is not valid. It may have been replaced. Unknown or switched off. Use a live key.
403 paused This account is paused. Write to us to switch it back on. Write to support@rentalpassport.app.
429 slow_down Too many checks. The limit is 120 a minute for each key. Wait, then retry. See Rate limits.
400 bad_request Send the renter's Passport link, or the code at the end of it. The code is not 16 to 64 characters of A-Z a-z 0-9 - _.
404 not_found This Passport link is not active. Ask the renter for a new one. Unknown code, expired, or switched off by the renter.
402 card_needed Your 5 free renters are used. Add a card at https://rentalpassport.app/developers to keep going: $5 per renter each month, and checking the same renter again that month is free. Add a card on /developers. Your free renters, and renters already counted this month, still work.

401, 403 and 429 can come from any endpoint. 400, 404 and 402 come only from a Passport check.

Refused calls are not counted, not billed and not shown to the renter.

Handling them

const NEXT_STEP = {
  unauthorized: 'Check the key, or make a new one on /developers.',
  paused: 'Write to support@rentalpassport.app.',
  slow_down: 'Wait a few seconds, then retry.',
  bad_request: 'Send the code from the renter\'s link.',
  not_found: 'Ask the renter for a new link.',
  card_needed: 'Add a card at https://rentalpassport.app/developers.',
};

const res = await fetch(`https://rentalpassport.app/api/v1/passports/${code}`, {
  headers: { Authorization: `Bearer ${process.env.RP_KEY}` },
});
if (!res.ok) {
  const { error } = await res.json();
  throw new Error(`${res.status} ${error.code}: ${NEXT_STEP[error.code] ?? error.message}`);
}

Only slow_down is worth retrying unchanged. The others need a new link, a key, a card or a word with us.

MCP

At POST /api/mcp, 401, 403 and 429 come back as HTTP errors in the shape above, before any JSON-RPC is read.

After that the server answers in JSON-RPC 2.0, with HTTP 200:

Case Answer
Body is not JSON HTTP 400, JSON-RPC error -32700, "The body is not valid JSON."
Not a JSON-RPC 2.0 request Error -32600
Unknown tool name Error -32602, "Unknown tool: ..."
Unknown method Error -32601, "Method not found: ..."
verify_passport refused (400, 404, 402 above) A tool result with isError: true and the message as text
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "content": [{ "type": "text", "text": "This Passport link is not active. Ask the renter for a new one." }],
    "isError": true
  }
}

GET and DELETE on /api/mcp return 405 with Allow: POST. See MCP server.

Errors · Docs · Rental Passport