Test API Key
Inspect the current status and metadata of one organization API key without rotating or revealing its secret.
Endpoint contract
Use the exact method and path shown above. Paths are relative to the API base URL.
Authentication, permission, and scope
| Control | Required contract |
|---|---|
| Authentication | Bearer access token for an active organization member. |
| Permission or scope | api_keys.view capability and admin:read scope. |
| Resource scope | The key must belong to the caller’s organization and selected project context. |
Request fields
| Field | Type | Contract |
|---|---|---|
key_id | integer path parameter | Required API-key record ID. This is not the raw secret. |
| Request body | none | Do not send a JSON body. |
Code examples
import osfrom memorysync import ControlPlaneClientclient = ControlPlaneClient(base_url="https://api.memorysync.io",access_token=os.environ["MEMORYSYNC_ACCESS_TOKEN"],)result = client.test_api_key(41,project_id=os.environ["MEMORYSYNC_PROJECT_ID"],)
Response shape
{"key_id":41,"valid":true,"status":"active","environment":"production","rate_limit_tier":"pro","scopes":["memories:read"],"project_id":"project_abc123","last_used_at":"2026-07-31T10:00:00Z","expires_at":null,"expired":false,"server_time":"2026-08-01T12:00:00Z"}
validis true only when the key is active and not expired.- The response contains metadata, never the secret value.
Status outcomes
Read the operation-specific response and persist only fields needed by the task.
Fix invalid path, query, or body fields before trying again.
Refresh authentication or verify the required organization permission and scope.
Treat the resource as unavailable without revealing whether it exists elsewhere.
Use returned retry metadata when present and reconcile uncertain mutations before repeating them.
Production handling
- 01
Authorize
APPConfirm the signed-in principal may perform this product action.
- 02
Validate
INPUTValidate identifiers and body fields before sending the request.
- 03
Call
SDKUse the named ControlPlaneClient method or equivalent HTTPS request from a trusted application context.
- 04
Inspect
RESULTUse
valid,status, andexpiredto render the current state. - 05
Reconcile
SAFEA valid metadata result does not replace a real operation-level integration check.
Security notes
Required
Keep organization controls inside trusted boundaries.
- Use the database key ID, not a secret, in the path.
- Do not log bearer tokens or attempt to reconstruct the API key.
- Treat a 404 as unavailable in the current scope.
Avoid
Do not weaken the route contract in client code.
- Do not expose bearer or refresh tokens in URLs, logs, or public clients.
- Do not accept organization, member, project, or resource IDs without application authorization.
- Do not treat returned data as trusted HTML, prompt instructions, or proof of application authorization.