{
  "openapi": "3.1.0",
  "info": {
    "title": "PikaMail Receive-Only API",
    "version": "2.0.0",
    "description": "Create permanent email accounts and read received messages. No sending or forwarding endpoint exists. Human guide: https://pikamail.life/api-docs.html. AI-readable guide: https://pikamail.life/llm-api-docs.txt."
  },
  "servers": [{"url":"https://pikamail.life/api/v1"}],
  "security": [{"ApiKey":[]}],
  "components": {
    "securitySchemes": {"ApiKey":{"type":"http","scheme":"bearer","description":"Website account API key starting pm_live_."}},
    "schemas": {
      "Error": {"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},
      "Inbox": {"type":"object","required":["id","address","domain","permanent","expires"],"properties":{"id":{"type":"string"},"address":{"type":"string","format":"email"},"domain":{"type":"string","description":"Selected domain returned by GET /domains."},"permanent":{"type":"boolean"},"created":{"type":"integer","description":"Unix milliseconds"},"expires":{"type":["integer","null"],"description":"Unix milliseconds, null for permanent accounts"}}},
      "MessageSummary": {"type":"object","required":["id","received","expires","from","subject","attachmentCount"],"properties":{"id":{"type":"string"},"received":{"type":"integer"},"expires":{"type":"integer"},"from":{"type":"string"},"subject":{"type":"string"},"attachmentCount":{"type":"integer"}}},
      "Message": {"type":"object","properties":{"id":{"type":"string"},"received":{"type":"integer"},"expires":{"type":"integer"},"from":{"type":"string"},"subject":{"type":"string"},"text":{"type":"string"},"html":{"type":"string","description":"Sanitized HTML. Render in sandbox without remote resources."},"attachments":{"type":"array","description":"Blocked attachment metadata; no bytes or download endpoint.","items":{"type":"object"}}}}
    },
    "parameters": {
      "InboxId":{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Email local part, not the full address."},
      "MessageId":{"name":"messageId","in":"path","required":true,"schema":{"type":"string"}}
    },
    "responses": {
      "Error":{"description":"JSON error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},
      "Ok":{"description":"Operation completed","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"const":true}}}}}}
    }
  },
  "paths": {
    "/domains":{"get":{"operationId":"listDomains","summary":"List available domains","responses":{"200":{"description":"Available domains","content":{"application/json":{"schema":{"type":"object","properties":{"domains":{"type":"array","items":{"type":"string"}}}}}}},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},
    "/inboxes":{"get":{"operationId":"listInboxes","summary":"List own and managed permanent inboxes","responses":{"200":{"description":"Inboxes","content":{"application/json":{"schema":{"type":"object","properties":{"inboxes":{"type":"array","items":{"$ref":"#/components/schemas/Inbox"}}}}}}},"401":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}},"post":{"operationId":"createPermanentAccount","summary":"Create a permanent website-login email account","description":"Maximum 1,000 managed accounts per owner and 3 creations per second per owner, also subject to a shared 3/source-IP/second and 30/global/second creation limit. Recovery code is returned only once.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["password"],"properties":{"alias":{"type":"string","pattern":"^[a-z][a-z0-9]{8,14}$","description":"Optional; omit for random 15-character name."},"domain":{"type":"string","description":"Optional enabled domain from GET /domains; defaults to the primary domain."},"password":{"type":"string","minLength":6},"kind":{"const":"permanent"}}}}}},"responses":{"201":{"description":"Created permanent account","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Inbox"},{"type":"object","required":["recoveryCode"],"properties":{"recoveryCode":{"type":"string","description":"Shown only once; store privately."}}}]}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"409":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},
    "/accounts/{id}":{"delete":{"operationId":"deleteManagedAccount","summary":"Permanently delete an account created by this API key owner","parameters":[{"$ref":"#/components/parameters/InboxId"}],"responses":{"200":{"$ref":"#/components/responses/Ok"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}},
    "/inboxes/{id}":{"parameters":[{"$ref":"#/components/parameters/InboxId"}],"get":{"operationId":"getInbox","summary":"Get inbox metadata","responses":{"200":{"description":"Inbox","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inbox"}}}},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}},"delete":{"operationId":"deleteSecondaryInbox","summary":"Delete a secondary inbox; cannot delete primary address","responses":{"200":{"$ref":"#/components/responses/Ok"},"403":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}},
    "/inboxes/{id}/messages":{"parameters":[{"$ref":"#/components/parameters/InboxId"}],"get":{"operationId":"listMessages","summary":"List newest received message metadata","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"before","in":"query","schema":{"type":"string"},"description":"Pass the previous response's nextBefore cursor unchanged."}],"responses":{"200":{"description":"Page of messages","content":{"application/json":{"schema":{"type":"object","properties":{"messages":{"type":"array","items":{"$ref":"#/components/schemas/MessageSummary"}},"nextBefore":{"type":["string","null"],"description":"Opaque timestamp:id cursor; null means no next page."}}}}}},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"}}}},
    "/inboxes/{id}/messages/{messageId}":{"parameters":[{"$ref":"#/components/parameters/InboxId"},{"$ref":"#/components/parameters/MessageId"}],"get":{"operationId":"getMessage","summary":"Read received message detail","responses":{"200":{"description":"Message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Message"}}}},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}},"delete":{"operationId":"deleteMessage","summary":"Delete a received message","responses":{"200":{"$ref":"#/components/responses/Ok"},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}}
  },
  "x-rate-limits":{"perKeyPerSecond":10,"globalPerSecond":100,"mailCreationsPerIpPerSecond":3,"mailCreationsPerOwnerPerSecond":3,"mailCreationsGlobalPerSecond":30,"recommendedPollSeconds":10,"retryAfterHeader":"seconds"}
}
