{
  "id": "audit-signing-1",
  "title": "Audit Signing: Manage Signing Key Configurations via REST",
  "description": "Full lifecycle of an Audit Signing configuration through the Config API: create a platform-managed config, create one backed by your own AWS KMS key, read it back with masked auth_params, update it with ETag concurrency control to rotate the key, and delete it.",
  "category": "Audit Signing",
  "tags": [
    "Audit Signing",
    "Config API",
    "KMS",
    "Key Management",
    "BYOK",
    "ETag",
    "Audit Records"
  ],
  "api": "Audit Signing",
  "language": "Json",
  "lastUpdated": "2026-10-20",
  "openApiEndpoints": [
    "/configs/v1/audit-signings",
    "/configs/v1/audit-signings/{id}"
  ],
  "relatedGuides": [
    "/guides/guide-audit-signing",
    "/guides/guide-audit-log",
    "/guides/guide-credentials",
    "/guides/guide-environment"
  ],
  "commonErrors": [
    {
      "code": "422",
      "message": "key_resource is required for customer-managed providers / kid is required for customer-managed providers / provider is required",
      "solution": "Every customer-managed provider (CUSTOMER_GCP_KMS, CUSTOMER_AWS_KMS, CUSTOMER_AZURE_KEY_VAULT) needs both key_resource and kid; provider itself is required on both create and update."
    },
    {
      "code": "412",
      "message": "Precondition Failed",
      "solution": "The If-Match ETag on update or delete no longer matches the stored configuration - re-read to get the current ETag and retry."
    },
    {
      "code": "409",
      "message": "audit signing config already exists in project",
      "solution": "A project holds exactly one Audit Signing configuration. Update (PUT) or delete the existing one instead of creating a second."
    },
    {
      "code": "404",
      "message": "Not Found",
      "solution": "No configuration with that GID or name in the project (reads by name need the project_id query parameter); deleted configurations also return 404."
    }
  ],
  "summary": "This example demonstrates the Audit Signing configuration REST endpoints (/configs/v1/audit-signings).\n\nWhat is an Audit Signing configuration?\nIt declares who manages the cryptographic key used to sign your project's audit records, making them tamper-evident:\n- PLATFORM_MANAGED: IndyKite manages the signing key (provider is required on create; there is no default)\n- CUSTOMER_GCP_KMS / CUSTOMER_AWS_KMS / CUSTOMER_AZURE_KEY_VAULT: the configuration names your own key\n  in your cloud key store, stored for the upcoming customer-managed key support (today the\n  platform-managed key signs every record) - identified by key_resource (e.g. the AWS KMS key ARN, max 256 chars)\n  and kid (the key ID stamped on signatures, max 256 chars), with provider access material\n  in auth_params (max 32 string pairs, each key and value 1-256 chars; the key names are not\n  prescribed by the platform, the examples follow each cloud's own guidance for third-party access)\n\nKey behaviors shown:\n1. Create with defaults - name, project_id and provider. A project holds exactly one\n   configuration: a second POST for the same project_id is refused with 409 and\n   \"audit signing config already exists in project\"\n2. Create with a customer-managed key (in a project that has none yet) - key_resource and kid become required\n3. Read - by GID or by name + project_id; auth_params values come back masked as empty strings\n4. Update with If-Match ETag - rotate to a new key by changing key_resource and kid\n5. Delete with the If-Match header - 200 with the deleted configuration's id\n\nValidation errors are explicit: a 422 response lists the exact reason, e.g.\n\"key_resource is required for customer-managed providers\".",
  "usecase": "Scenario: A compliance team must prove that audit records have not been altered, using a signing key the company controls.\n\nFlow:\n1. The team creates an AWS KMS key and an IAM role that permits signing with it\n2. Ops creates an Audit Signing configuration: provider CUSTOMER_AWS_KMS,\n   key_resource = the key's ARN, kid = \"audit-2026-q3\", auth_params.role_arn = the role\n   and auth_params.external_id = the external ID in its trust policy\n3. The configuration is stored for the upcoming customer-managed key support; every batch,\n   manifest and checkpoint in the Audit Log API carries the kid of the key that signed it,\n   today the platform key's, and verifiers use that kid to select the right public key from the JWKS\n4. At the quarterly rotation, ops PUTs the configuration with the new key ARN and\n   kid \"audit-2026-q4\", guarded by If-Match so concurrent edits fail loudly (412)\n5. Reading the configuration never leaks secrets: auth_params values are masked\n\nKey custody stays with the company: the key never leaves AWS, and the kid on each\nrecord in the Audit Log API shows which key signed it.",
  "requirements": "Prerequisites:\n- ServiceAccount credentials: All /configs/v1/audit-signings endpoints authenticate with a Service Account Bearer token\n- Project GID: The project (application space) the configuration belongs to\n- For customer-managed providers: a signing key in GCP KMS, AWS KMS, or Azure Key Vault, plus the access material the platform should use (e.g. an AWS IAM role ARN)\n\nField constraints:\n- name: URL-friendly, unique in the project, immutable\n- display_name: 2-254 chars (optional)\n- description: 2-65000 chars (optional)\n- provider: PLATFORM_MANAGED | CUSTOMER_GCP_KMS | CUSTOMER_AWS_KMS | CUSTOMER_AZURE_KEY_VAULT\n- key_resource, kid: max 256 chars; required for every customer-managed provider\n- auth_params: up to 32 string pairs; write-only (masked on read)",
  "steps": "Step 1: Create a platform-managed configuration\n- POST /configs/v1/audit-signings with name, project_id, provider PLATFORM_MANAGED\n- Result: 201 with id, timestamps, authorship - and an ETag response header\n\nStep 2: Create a customer-managed configuration (AWS KMS)\n- POST with provider CUSTOMER_AWS_KMS, key_resource (key ARN), kid, auth_params.role_arn and external_id\n- In a project that already has a configuration this returns 409 \"audit signing config already exists in project\": use a different project, or update the existing configuration (step 5)\n- Omitting key_resource or kid returns 422 with the exact validation error\n\nStep 3: Read the configuration\n- GET /configs/v1/audit-signings/{id}, or /{name}?project_id=<gid>; optional version query parameter\n- auth_params values are masked as empty strings; response carries a fresh ETag\n\nStep 4: List the project's configuration\n- GET /configs/v1/audit-signings?project_id=<gid> returns { \"data\": [...] } with at most one item\n\nStep 5: Update to rotate the key\n- PUT /configs/v1/audit-signings/{id} with If-Match: <etag>; provider is required on update\n- New key_resource + new kid = key rotation; a stale ETag returns 412 Precondition Failed\n- For display_name/description: null keeps the value, empty string removes it\n\nStep 6: Delete\n- DELETE /configs/v1/audit-signings/{id} with If-Match: <etag> returns 200 with { \"id\": \"<gid>\" }",
  "code": [
    {
      "step": "Step 1",
      "description": "Create a platform-managed Audit Signing configuration - the minimal form. Choose PLATFORM_MANAGED provider.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/audit-signings",
      "language": "Json",
      "ingest": {
        "name": "audit-signing-default",
        "project_id": "gid-of-project",
        "provider": "PLATFORM_MANAGED"
      }
    },
    {
      "step": "Step 2",
      "description": "Create a configuration backed by your own AWS KMS key. key_resource identifies the key (its ARN), kid is the key ID stamped on signatures, and auth_params carries the access material (here an IAM role ARN). For GCP KMS or Azure Key Vault, use that provider's key identifier in key_resource.",
      "filename": "POST https://eu.api.indykite.com/configs/v1/audit-signings",
      "language": "Json",
      "ingest": {
        "name": "audit-signing-byok",
        "display_name": "Audit signing with our AWS KMS key",
        "description": "Signs audit records with the compliance team key",
        "project_id": "gid-of-project",
        "provider": "CUSTOMER_AWS_KMS",
        "key_resource": "arn:aws:kms:us-east-1:123456789012:key/example-key-id",
        "kid": "audit-2026-q3",
        "auth_params": {
          "role_arn": "arn:aws:iam::123456789012:role/indykite-audit-signer",
          "external_id": "a-value-you-generated"
        }
      }
    },
    {
      "description": "Create response (201): the configuration GID, timestamps, and authorship. Save the ETag response header for Step 5 and Step 6.",
      "language": "Json",
      "code": "\n{\n  \"id\": \"gid:example-audit-signing-config-id\",\n  \"create_time\": \"2026-09-03T09:00:00Z\",\n  \"created_by\": \"gid:example-service-account-id\",\n  \"update_time\": \"2026-09-03T09:00:00Z\",\n  \"updated_by\": \"gid:example-service-account-id\"\n}"
    },
    {
      "step": "Step 3",
      "description": "Read the configuration by GID, or by name with the project_id query parameter.",
      "filename": "GET https://eu.api.indykite.com/configs/v1/audit-signings/{id}",
      "language": "Bash",
      "code": "curl <API_URL>/configs/v1/audit-signings/<id-or-name>?project_id=<gid-of-project> \\\n  -H \"Authorization: Bearer $SERVICE_ACCOUNT_TOKEN\""
    },
    {
      "description": "Read response: all fields plus organization_id - with auth_params values masked as empty strings. Secrets never round-trip.",
      "language": "Json",
      "code": "\n{\n  \"id\": \"gid:example-audit-signing-config-id\",\n  \"name\": \"audit-signing-byok\",\n  \"display_name\": \"Audit signing with our AWS KMS key\",\n  \"description\": \"Signs audit records with the compliance team key\",\n  \"create_time\": \"2026-09-03T09:00:00Z\",\n  \"created_by\": \"gid:example-service-account-id\",\n  \"update_time\": \"2026-09-03T09:00:00Z\",\n  \"updated_by\": \"gid:example-service-account-id\",\n  \"organization_id\": \"gid:example-organization-id\",\n  \"project_id\": \"gid-of-project\",\n  \"provider\": \"CUSTOMER_AWS_KMS\",\n  \"key_resource\": \"arn:aws:kms:us-east-1:123456789012:key/example-key-id\",\n  \"kid\": \"audit-2026-q3\",\n  \"auth_params\": {\n    \"role_arn\": \"\",\n    \"external_id\": \"\"\n  }\n}"
    },
    {
      "step": "Step 4",
      "description": "List every Audit Signing configuration in the project.",
      "filename": "GET https://eu.api.indykite.com/configs/v1/audit-signings?project_id=<gid>",
      "language": "Bash",
      "code": "curl <API_URL>/configs/v1/audit-signings?project_id=<gid-of-project> \\\n  -H \"Authorization: Bearer $SERVICE_ACCOUNT_TOKEN\"\n# Response: { \"data\": [ <one read response object per configuration> ] }"
    },
    {
      "step": "Step 5",
      "description": "Rotate the key: PUT with If-Match carrying the last ETag, pointing key_resource at the new key and bumping kid so verifiers can tell old signatures from new. provider is required on update.",
      "filename": "PUT https://eu.api.indykite.com/configs/v1/audit-signings/{id}",
      "language": "Bash",
      "code": "curl -X PUT <API_URL>/configs/v1/audit-signings/<id> \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $SERVICE_ACCOUNT_TOKEN\" \\\n  -H \"If-Match: $ETAG\" \\\n  -d '{\n    \"provider\": \"CUSTOMER_AWS_KMS\",\n    \"key_resource\": \"arn:aws:kms:us-east-1:123456789012:key/rotated-key-id\",\n    \"kid\": \"audit-2026-q4\",\n    \"auth_params\": {\n      \"role_arn\": \"arn:aws:iam::123456789012:role/indykite-audit-signer\",\n      \"external_id\": \"a-value-you-generated\"\n    }\n  }'"
    },
    {
      "step": "Step 6",
      "description": "Delete the configuration, guarded by the If-Match header carrying the last ETag. The 200 response echoes the deleted configuration's id.",
      "filename": "DELETE https://eu.api.indykite.com/configs/v1/audit-signings/{id}",
      "language": "Bash",
      "code": "curl -X DELETE \"<API_URL>/configs/v1/audit-signings/<id>\" \\\n  -H \"Authorization: Bearer $SERVICE_ACCOUNT_TOKEN\" \\\n  -H \"If-Match: $ETAG\"\n# Response: 200 OK\n# {\"id\": \"<gid-of-deleted-configuration>\"}"
    },
    {
      "description": "Validation error contract: creating a customer-managed configuration without its key fields returns 422 with the exact reason in the errors array.",
      "language": "Json",
      "code": "\n{\n  \"message\": \"Unprocessable Entity\",\n  \"errors\": [\n    \"key_resource is required for customer-managed providers\"\n  ]\n}"
    },
    {
      "description": "Uniqueness contract: a project holds exactly one Audit Signing configuration, so a second POST for the same project_id returns 409.",
      "language": "Json",
      "code": "\n{\n  \"message\": \"Conflict\",\n  \"errors\": [\n    \"audit signing config already exists in project\"\n  ]\n}"
    }
  ],
  "links": {
    "html": "/resources/audit-signing-1",
    "markdown": "/resources/audit-signing-1.md",
    "openApi": "https://openapi.indykite.com/"
  }
}