Overview
The Public Service is PCX’s externally-facing integration layer. Unlike all other PCX services — which use Bearer JWT tokens issued through the user auth flow — the Public API authenticates using API keys passed in theX-API-Key request header. This makes it suitable for server-to-server integrations where a persistent credential is needed without a user login flow.
When a valid API key is presented, the service resolves the caller’s organisation (org_id) and user (user_id) automatically. These identities are then used to scope all operations without requiring them to be repeated in every request body.
Authentication
Every request must include the API key in theX-API-Key header:
401 with { "message": "API Key is missing", "status": "error" }.
API keys are created and managed through the API Keys endpoints below.
API Keys
API keys are the primary credential for the Public API. Each key is scoped to anorg_id and a user_id and can be independently activated, revoked, or deleted.
Key lifecycle
- Create —
POST /public/api-keys/create. The response includes the full key value exactly once. Store it immediately; it cannot be retrieved afterwards. - List —
GET /public/api-keys?org_id=<id>. Returns paginated key metadata (prefix, name, status, timestamps). The secret value is never returned. - Revoke —
PATCH /public/api-keys/{prefix}/revoke. Disables the key without deleting the record. Useful when a key may have been exposed — it preserves the audit trail while immediately cutting off access. - Delete —
DELETE /public/api-keys/{prefix}. Permanently removes the key. Use when a key is no longer needed and the record is not required for compliance purposes.
Key identification
Keys are identified in two ways:| Identifier | Used for |
|---|---|
api_key_id | Fetching key metadata via GET /public/api-keys/{api_key_id} |
prefix | Revoking or deleting via the {prefix} path parameter |
prefix is a short, non-secret substring of the key (e.g. pcx_abc123) that uniquely identifies it without exposing the full secret.
Webhooks
Webhooks let you receive real-time transaction events at your own endpoint. The flow is:- Register —
POST /public/webhooks. Provide anendpoint_url(must be HTTPS and publicly reachable). The org is inferred from your API key — noorg_idneeded. - Receive — PCX dispatches a POST to your endpoint whenever a transaction update occurs. Your endpoint should return
2xxto acknowledge receipt. - Notify —
POST /public/webhooks/notify. Programmatically push atransaction_datapayload to all registered webhook endpoints for a givenorg_id. This is useful for manually triggering notifications during testing or replaying missed events.
Webhook payload
Thetransaction_data field in the notify request is a free-form object. A typical payload looks like:
Pagination
List endpoints (e.g.GET /public/api-keys) use DynamoDB cursor pagination. Pass last_evaluated_key from meta.last_evaluated_key in the previous response to fetch the next page. When the value is null, you have reached the last page.