> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anycrm.anyreach.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete an Organization API Key

Deleting the local `pats` row is what actually revokes the key: [the exchange](/api-reference/pats/exchange) looks the key up there on every request, so a deleted row means an immediate `401` for anything still using it.

Row-level security scopes the lookup to the caller's active organization, so an `id` from a different org behaves exactly like an unknown one — `404`, never a `403` that would confirm the row exists elsewhere. The paired Logto-side personal access token is deleted first, addressed by the key's *owner* rather than the caller, so an admin revoking someone else's key cleans up the right upstream token instead of orphaning it. A Logto-side `404` — already gone, nothing left to orphan — is tolerated and logged, and the local row is still deleted.

### Auth

Requires `pats:delete` and an active organization.

By default you can only delete **your own** keys: the lookup is filtered on the caller's `user_id`, so another member's `id` returns the same `404` as an unknown one and gives you no way to enumerate keys you don't own. Row-level security alone does not cover this — it enforces only the organization boundary.

A caller holding `organizations:manage` (the `admin` role) may delete **any** key in the organization, so a departed member's integration key stays revokable. Admin revocations of someone else's key are logged with both user ids.

### Response

```json 200 theme={null}
{ "message": "PAT deleted successfully" }
```

### Errors

| Status                         | Cause                                                                                                                                                                                                                                                                                                         |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `404 Not Found`                | No key with this `id` in the caller's organization — or, without `organizations:manage`, a key in it that belongs to another member.                                                                                                                                                                          |
| *Logto's own status, verbatim* | Deleting the paired token from Logto failed for a reason other than "already gone." Logto's status code is re-raised as-is with a generic `Failed to delete token from identity provider.` detail — so a Logto `403` surfaces to you as a `403`, which is easy to misread as *your* token lacking permission. |
| `500 Internal Server Error`    | Logto was unreachable (transport-level failure — connection refused, DNS, timeout).                                                                                                                                                                                                                           |


## OpenAPI

````yaml DELETE /organization-pats/{id}
openapi: 3.1.0
info:
  title: anycrm-api
  version: 0.0.1
servers: []
security: []
tags:
  - name: Customer Intelligence
    description: >-
      Company research and ICP-fit scoring — create a research run, track its
      progress, and read back scored companies as leads.
  - name: Outreach
    description: >-
      The cold-email management console — domains, mailboxes, and campaigns — as
      a thin control plane over the SalesForge stack.
  - name: AnyCard
    description: >-
      Authenticated CRUD for AnyCard, the org's digital business-card /
      lead-capture product.
  - name: AnyCard Events
    description: >-
      Event-attribution analytics for AnyCard — which captured leads converted,
      broken down by source, owner, and deal.
  - name: AnyCard Share Links
    description: >-
      Unauthenticated endpoints reached by anyone who scans a QR code or opens a
      shared AnyCard link.
  - name: AI
    description: >-
      A streaming (SSE) AI chat endpoint with account-commit actions it can take
      on the caller's behalf.
  - name: Analytics Assistant
    description: >-
      The natural-language analytics assistant — a guarded text-to-SQL loop
      (SSE) that answers ad-hoc questions over the org's CRM data as a
      least-privilege, read-only database role.
  - name: Account Readiness
    description: >-
      Account Readiness Profiles — AI-scored signals on whether an account is
      ready for outreach or expansion, computed via a Temporal workflow.
  - name: Integrations
    description: >-
      Pipedream Connect — issuing connect tokens and managing the org's
      connected third-party accounts.
  - name: Feedback
    description: >-
      User-submitted platform feedback (bug reports, feature requests) — global,
      not scoped to one organization.
  - name: Public Media
    description: >-
      Unauthenticated image reads for publicly-embeddable assets (card photos,
      inline email images) — allowlisted by key shape; everything else in the
      storage bucket stays private.
  - name: Service Health
    description: Service liveness.
paths:
  /organization-pats/{id}:
    delete:
      tags:
        - PATs
      summary: Delete Pat
      operationId: delete_pat_organization_pats__id__delete
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            description: The organization API key's id.
            title: Id
          description: The organization API key's id.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    MessageResponse:
      properties:
        message:
          type: string
          title: Message
      type: object
      required:
        - message
      title: MessageResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````