This guide covers API namespace management endpoints for creating and managing API containers that organize your keys.

Overview

API endpoints manage the namespaces that contain your keys, providing CRUD operations for API management and key listing.

Key Changes in v2:

  • Response format: Direct responses → {meta, data} envelope
  • HTTP methods: Some GET → POST changes for consistency
  • Enhanced responses: Request IDs for debugging and pagination metadata
  • Consistent structure: All responses follow same envelope pattern

Migration Impact:

  • Existing in v1: Full API CRUD operations and key listing functionality
  • Enhanced in v2: Improved response format, better pagination, and enhanced filtering
  • Maintained in v2: All core API management functionality with consistent request patterns

POST /v1/apis.createApi → POST /v2/apis.createApi

Key Changes:
  • Response format: Direct response → {meta, data} envelope
Create API Request
{
  "name": "Production API"
}

GET /v1/apis.getApi → POST /v2/apis.getApi

Key Changes:
  • HTTP method: GET → POST
  • Request body format required instead of query parameters
  • Response format: Direct response → {meta, data} envelope
HTTP Method & Parameter Change
# v1: GET with query parameters
curl -X GET "https://api.unkey.dev/v1/apis.getApi?apiId=api_123"
  -H "Authorization: Bearer <your-root-key>"

# v2: POST with request body
curl -X POST https://api.unkey.com/v2/apis.getApi
  -H "Authorization: Bearer <your-root-key>"
  -H "Content-Type: application/json"
  -d '{"apiId": "api_123"}'

GET /v1/apis.listKeys → POST /v2/apis.listKeys

Key Changes:
  • HTTP method: GET → POST
  • Request body format required instead of query parameters
  • Enhanced filtering and pagination options
  • Response format: Direct response → {meta, data} envelope
List Keys Request Diff
// v1: Query parameters only
// ?apiId=api_123&limit=100

// v2: Request body with enhanced options
{
  "apiId": "api_123",
  "limit": 100,
  "cursor": "optional_cursor_for_pagination", 
  "externalId": "optional_filter_by_external_id"
}

POST /v1/apis.deleteApi → POST /v2/apis.deleteApi

Key Changes:
  • Response format: Direct response → {meta, data} envelope
Delete API Request
{
  "apiId": "api_123"
}

POST /v1/apis.deleteKeys → Removed in v2

Purpose: Delete all keys within an API namespace. Migration Path: Use individual POST /v2/keys.deleteKey calls for each key or delete the entire API with POST /v2/apis.deleteApi.
v1: Delete all keys in API
curl -X POST https://api.unkey.dev/v1/apis.deleteKeys
  -H "Authorization: Bearer <your-root-key>"
  -H "Content-Type: application/json"
  -d '{"apiId": "api_123"}'