rawApiKey field in the response contains the full key value — this is the only time it will ever be returned. AgriBackup stores only a cryptographic hash of the key after generation, so you must copy and store it securely before closing the response. If the key is lost, you will need to rotate it to obtain a new value.
POST /api/v1/enterprise/api-keys
Request Body
A descriptive label for the key that identifies its intended purpose or owning integration (for example,
"Production ERP Integration" or "CI/CD Pipeline Key"). This name is displayed in audit logs and the key listing.Example: "Default Sandbox Key"An array of permission scope strings that govern which endpoints this key may call. Use
["*"] to grant unrestricted access to all enterprise endpoints. For tighter access control, specify individual scopes such as ["risk:read", "suppliers:write"].Example: ["*"]Code Examples
Response
A201 Created response confirms the key was generated. The rawApiKey field contains the plaintext key — copy it immediately.
The unique identifier assigned to this API key. Use this as the
keyId path parameter when rotating or deleting the key.The descriptive label you provided in the request, confirmed in the response.
The plaintext API key value. This string is returned exactly once at generation time. AgriBackup does not store this value after the response is sent. Store it in a secrets manager (e.g., HashiCorp Vault, AWS Secrets Manager) immediately.
The permission scopes assigned to the key, as provided in the request.
The UTC timestamp at which the key was generated.
Error Responses
| HTTP Status | Error Code | Description |
|---|---|---|
400 Bad Request | VALIDATION_FAILED | The request body is missing required fields (name or scopes), or scopes is an empty array. |
401 Unauthorized | UNAUTHORIZED | The Authorization header is absent or the bearer token is invalid. |
403 Forbidden | FORBIDDEN | The authenticated identity does not have permission to create API keys for this organization. |
429 Too Many Requests | RATE_LIMITED | You have exceeded the hourly rate limit. Check X-RateLimit-Reset for your reset time. |