API Keys API Reference
Complete reference for the API Keys API endpoints.
Base URL
https://api.orcarail.com/api/v1
Create an API Key
Create a new API key for a specific organization.
POST /organizations/:organizationId/api-keys
Authentication
- Bearer Token (JWT) - Required
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
organizationId | string | Yes | Organization ID to create the key for. The bearer token must have access. |
Use the organization id from Dashboard → Organization Settings or your organizations list API response. The path parameter is required; API keys are created for that exact organization.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | No | Descriptive name for the API key |
webhookUrl | string | No | Webhook URL to receive payment events |
Response
{
"apiKey": {
"id": 1,
"name": "Production API Key",
"keyPrefix": "ak_live_",
"status": "active",
"webhookUrl": "https://api.example.com/webhooks/orcarail",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
},
"key": "ak_live_abc123def456",
"secret": "sk_live_xyz789uvw012"
}
:::warning Important
The secret is only shown once. Save it immediately!
:::
List API Keys
List all API keys for a specific organization.
GET /organizations/:organizationId/api-keys
Authentication
- Bearer Token (JWT) - Required
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
organizationId | string | Yes | Organization ID to list keys for. The bearer token must have access. |
The list is scoped only to the organization in the path; OrcaRail does not infer a different organization from the session when this parameter is present.
Response
[
{
"id": 1,
"name": "Production API Key",
"keyPrefix": "ak_live_",
"status": "active",
"createdAt": "2024-01-01T00:00:00.000Z"
},
{
"id": 2,
"name": "Development API Key",
"keyPrefix": "ak_live_",
"status": "active",
"createdAt": "2024-01-02T00:00:00.000Z"
}
]
Update an API Key
Update an API key's name or webhook URL.
PATCH /api-keys/:id
Authentication
- Bearer Token (JWT) - Required
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | number | Yes | API key ID |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | No | Descriptive name for the API key |
webhookUrl | string | No | Webhook URL to receive payment events (set to null to remove) |
Response
{
"id": 1,
"name": "Updated API Key Name",
"keyPrefix": "ak_live_",
"status": "active",
"webhookUrl": "https://api.example.com/webhooks/orcarail",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
}
Revoke an API Key
Revoke an API key to disable it.
POST /api-keys/:id/revoke
Authentication
- Bearer Token (JWT) - Required
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | number | Yes | API key ID |
Response
{
"id": 1,
"name": "Production API Key",
"keyPrefix": "ak_live_",
"status": "revoked",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T12:00:00.000Z"
}
Test an API Key
Test if an API key is valid.
POST /api-keys/test
Authentication
- None required
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
key | string | Yes | API key (e.g., ak_live_...) |
secret | string | Yes | API secret (e.g., sk_live_...) |
Response
{
"ok": true
}
Error Response
If the API key is invalid:
{
"statusCode": 401,
"message": "Invalid API key",
"error": "Unauthorized"
}
API Key Object
Fields
| Field | Type | Description |
|---|---|---|
id | number | Unique identifier |
name | string | Descriptive name |
keyPrefix | string | First 8 characters of the key (e.g., ak_live_) |
status | string | Status: active or revoked |
webhookUrl | string | Webhook URL for receiving payment events (nullable) |
createdAt | string | ISO 8601 creation timestamp |
updatedAt | string | ISO 8601 last update timestamp |
Status Values
| Status | Description |
|---|---|
active | API key is active and can be used |
revoked | API key has been revoked and cannot be used |
Status Codes
| Status Code | Description |
|---|---|
200 | Success |
201 | Created |
400 | Bad Request |
401 | Unauthorized |
404 | Not Found |
500 | Internal Server Error |
Error Response Format
{
"statusCode": 400,
"message": "Invalid request",
"error": "Bad Request"
}
See Also
- API Keys Guide - Detailed API keys documentation
- Webhook Configuration - Configure webhooks for API keys
- Authentication Overview - Authentication methods