Skip to main content
Use this endpoint to permanently revoke an API key that is no longer needed or that you suspect has been compromised. Once deleted, any request that includes the revoked key in its Authorization header will immediately receive a 401 Unauthorized response — there is no grace period. This action is irreversible; if you need a replacement key with the same configuration, use the Rotate Key endpoint instead, which deactivates the old key and issues a new one atomically. DELETE /api/v1/enterprise/api-keys/{keyId}

Path Parameters

keyId
string
required
The unique identifier of the API key to permanently delete. Retrieve this value from the id field returned by the List API Keys or Generate API Key endpoints.Example: key_a1b2c3d4e5f6

Code Examples

import agribackup
from agribackup.rest import ApiException

configuration = agribackup.Configuration(host="https://live.agribackup.com/api/v1")
configuration.api_key["ApiKeyAuth"] = "sk_live_YOUR_API_KEY"

key_id = "key_a1b2c3d4e5f6"

with agribackup.ApiClient(configuration) as api_client:
    try:
        api_instance = agribackup.EnterpriseAPIKeysApi(api_client)
        api_instance.delete_api_key(key_id=key_id)
        print(f"Key {key_id} has been permanently revoked.")
    except ApiException as e:
        print("Exception when calling API: %s\n" % e)
import { AgriBackupClient } from "@agribackup/sdk";

const client = new AgriBackupClient({
  apiKey: "sk_live_YOUR_API_KEY",
  baseUrl: "https://live.agribackup.com/api/v1",
});

async function deleteApiKey(keyId) {
  try {
    await client.keys.deleteApiKey(keyId);
    console.log(`Key ${keyId} has been permanently revoked.`);
  } catch (error) {
    console.error(error);
  }
}

deleteApiKey("key_a1b2c3d4e5f6");
curl --request DELETE \
  --url https://live.agribackup.com/api/v1/enterprise/api-keys/key_a1b2c3d4e5f6 \
  --header "Authorization: Bearer sk_live_YOUR_API_KEY"

Response

A 200 OK response confirms the key has been permanently revoked and deleted.

Error Responses

HTTP StatusError CodeDescription
401 UnauthorizedUNAUTHORIZEDThe Authorization header is absent or the bearer token is invalid.
403 ForbiddenFORBIDDENThe authenticated identity does not have permission to delete API keys for this organization.
404 Not FoundNOT_FOUNDNo API key with the provided keyId exists for this organization, or the key has already been deleted.
429 Too Many RequestsRATE_LIMITEDYou have exceeded the hourly rate limit. Check X-RateLimit-Reset for your reset time.
{
  "code": "NOT_FOUND",
  "message": "API key not found",
  "details": [
    {
      "code": "KEY_NOT_FOUND",
      "field": "keyId",
      "issue": "No active API key with ID 'key_a1b2c3d4e5f6' exists for this organization"
    }
  ]
}