{
  "schemaVersion": 1,
  "operation": {
    "operationId": "updateCurrentAPIToken",
    "method": "PATCH",
    "path": "/api/v1/me/api-tokens/{token}",
    "summary": "Update current API token",
    "description": "",
    "tags": [
      "Current User"
    ],
    "effect": "write",
    "confirmation": "conditional",
    "parameters": [
      {
        "name": "token",
        "in": "path",
        "required": true,
        "description": "",
        "schema": {
          "type": "string"
        }
      },
      {
        "name": "If-Match",
        "in": "header",
        "required": true,
        "description": "",
        "schema": {
          "type": "string"
        }
      }
    ],
    "requestBody": {
      "required": true,
      "description": "",
      "content": [
        {
          "contentType": "application/json",
          "schema": {
            "$ref": "#/components/schemas/APITokenUpdateRequest"
          }
        }
      ]
    },
    "responses": [
      {
        "status": "200",
        "description": "The request has succeeded.",
        "content": [
          {
            "contentType": "application/json",
            "schema": {
              "$ref": "#/components/schemas/APITokenResponse"
            }
          }
        ]
      },
      {
        "status": "400",
        "description": "The server could not understand the request due to invalid syntax.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "401",
        "description": "Access is unauthorized.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "403",
        "description": "Access is forbidden.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "404",
        "description": "The server cannot find the requested resource.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "409",
        "description": "The request conflicts with the current state of the server.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "412",
        "description": "Precondition failed.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "413",
        "description": "Client error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "415",
        "description": "Client error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "422",
        "description": "Client error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "429",
        "description": "Client error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "500",
        "description": "Server error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "502",
        "description": "Server error",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      },
      {
        "status": "503",
        "description": "Service unavailable.",
        "content": [
          {
            "contentType": "application/problem+json",
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            }
          }
        ]
      }
    ]
  },
  "schemas": {
    "APITokenResponse": {
      "example": {
        "capabilities": [
          "PLATFORM_ADMIN"
        ],
        "createdAt": "2026-01-02T15:04:05Z",
        "description": "example",
        "expiresAt": "2026-01-02T15:04:05Z",
        "id": "example",
        "lastUsedAt": "2026-01-02T15:04:05Z",
        "modifiedAt": "2026-01-02T15:04:05Z",
        "name": "example",
        "permissionProfile": "leapview.permissions/v1",
        "permissions": [
          {
            "action": "dashboard.read",
            "profile": "leapview.permissions/v1",
            "target": {
              "projectId": "project:analytics",
              "resourceId": "dashboard:sales",
              "resourceKind": "dashboard",
              "scope": "resource"
            }
          }
        ],
        "revokedAt": "2026-01-02T15:04:05Z"
      },
      "properties": {
        "capabilities": {
          "description": "Legacy capability allowlist retained during migration. Legacy NULL values are returned as an empty deny-all list.",
          "example": [
            "PLATFORM_ADMIN"
          ],
          "items": {
            "$ref": "#/components/schemas/Capability"
          },
          "type": "array"
        },
        "createdAt": {
          "example": "2026-01-02T15:04:05Z",
          "format": "date-time",
          "type": "string"
        },
        "description": {
          "example": "example",
          "type": "string"
        },
        "expiresAt": {
          "example": "2026-01-02T15:04:05Z",
          "format": "date-time",
          "type": "string"
        },
        "id": {
          "example": "example",
          "type": "string"
        },
        "lastUsedAt": {
          "example": "2026-01-02T15:04:05Z",
          "format": "date-time",
          "type": "string"
        },
        "modifiedAt": {
          "example": "2026-01-02T15:04:05Z",
          "format": "date-time",
          "type": "string"
        },
        "name": {
          "example": "example",
          "type": "string"
        },
        "permissionProfile": {
          "$ref": "#/components/schemas/PermissionCatalogProfile",
          "description": "The versioned catalog profile for typed action-target permissions. Legacy capability-only rows omit this value."
        },
        "permissions": {
          "description": "The exact action-target pairs persisted for this token. Legacy capability-only rows expose an explicit empty array.",
          "example": [
            {
              "action": "dashboard.read",
              "profile": "leapview.permissions/v1",
              "target": {
                "projectId": "project:analytics",
                "resourceId": "dashboard:sales",
                "resourceKind": "dashboard",
                "scope": "resource"
              }
            }
          ],
          "items": {
            "$ref": "#/components/schemas/PermissionPair"
          },
          "type": "array"
        },
        "revokedAt": {
          "example": "2026-01-02T15:04:05Z",
          "format": "date-time",
          "type": "string"
        }
      },
      "required": [
        "id",
        "name",
        "description",
        "permissions",
        "createdAt",
        "modifiedAt"
      ],
      "type": "object"
    },
    "APITokenUpdateRequest": {
      "example": {
        "description": "example",
        "expectedModifiedAt": "2026-01-02T15:04:05Z",
        "expiresAt": "2026-01-02T15:04:05Z",
        "name": "example",
        "permissions": [
          {
            "action": "dashboard.read",
            "profile": "leapview.permissions/v1",
            "target": {
              "projectId": "project:analytics",
              "resourceId": "dashboard:sales",
              "resourceKind": "dashboard",
              "scope": "resource"
            }
          }
        ]
      },
      "properties": {
        "description": {
          "example": "example",
          "type": "string"
        },
        "expectedModifiedAt": {
          "description": "The modifiedAt value returned by the most recent read; stale edits are rejected.",
          "example": "2026-01-02T15:04:05Z",
          "format": "date-time",
          "type": "string"
        },
        "expiresAt": {
          "example": "2026-01-02T15:04:05Z",
          "format": "date-time",
          "type": "string"
        },
        "name": {
          "example": "example",
          "type": "string"
        },
        "permissions": {
          "example": [
            {
              "action": "dashboard.read",
              "profile": "leapview.permissions/v1",
              "target": {
                "projectId": "project:analytics",
                "resourceId": "dashboard:sales",
                "resourceKind": "dashboard",
                "scope": "resource"
              }
            }
          ],
          "items": {
            "$ref": "#/components/schemas/PermissionPair"
          },
          "type": "array"
        }
      },
      "required": [
        "name",
        "permissions",
        "expiresAt",
        "expectedModifiedAt"
      ],
      "type": "object"
    },
    "Capability": {
      "enum": [
        "PLATFORM_ADMIN",
        "PROJECT_ADMIN",
        "RESOURCE_USE",
        "RESOURCE_READ",
        "RESOURCE_EDIT",
        "RESOURCE_MANAGE",
        "RESOURCE_SHARE",
        "RESOURCE_PUBLISH"
      ],
      "example": "PLATFORM_ADMIN",
      "type": "string"
    },
    "PermissionAction": {
      "enum": [
        "dashboard.read",
        "dashboard.create",
        "dashboard.update",
        "dashboard.delete",
        "dashboard.publish",
        "semantic.read",
        "semantic.query",
        "semantic.consume",
        "semantic.create",
        "semantic.update",
        "semantic.delete",
        "source.read",
        "source.create",
        "source.update",
        "source.delete",
        "model.read",
        "model.create",
        "model.update",
        "model.delete",
        "pipeline.read",
        "pipeline.create",
        "pipeline.run",
        "pipeline.update",
        "pipeline.delete",
        "connection.read",
        "connection.create",
        "connection.use",
        "connection.manage",
        "connection.upload",
        "resource.share",
        "delivery.read",
        "delivery.plan",
        "delivery.build",
        "delivery.publish",
        "delivery.approve",
        "delivery.activate",
        "delivery.rollback",
        "project.settings.read",
        "project.settings.update",
        "project.access.read",
        "project.access.manage",
        "project.access.delegate",
        "audit.read",
        "workload.delegate",
        "platform.settings.read",
        "platform.settings.update",
        "platform.access.read",
        "platform.access.manage",
        "platform.audit.read",
        "instance.project.claim"
      ],
      "example": "dashboard.read",
      "type": "string"
    },
    "PermissionCatalogProfile": {
      "enum": [
        "leapview.permissions/v1"
      ],
      "example": "leapview.permissions/v1",
      "type": "string"
    },
    "PermissionPair": {
      "example": {
        "action": "dashboard.read",
        "profile": "leapview.permissions/v1",
        "target": {
          "projectId": "project:analytics",
          "resourceId": "dashboard:sales",
          "resourceKind": "dashboard",
          "scope": "resource"
        }
      },
      "properties": {
        "action": {
          "$ref": "#/components/schemas/PermissionAction"
        },
        "profile": {
          "$ref": "#/components/schemas/PermissionCatalogProfile"
        },
        "target": {
          "$ref": "#/components/schemas/PermissionTarget"
        }
      },
      "required": [
        "action",
        "target",
        "profile"
      ],
      "type": "object"
    },
    "PermissionScope": {
      "enum": [
        "instance",
        "project",
        "resource"
      ],
      "example": "instance",
      "type": "string"
    },
    "PermissionTarget": {
      "example": {
        "projectId": "project:analytics",
        "resourceId": "dashboard:sales",
        "resourceKind": "dashboard",
        "scope": "resource"
      },
      "properties": {
        "includeFuture": {
          "example": true,
          "type": "boolean"
        },
        "instanceId": {
          "example": "example",
          "type": "string"
        },
        "projectId": {
          "example": "example",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
          "type": "string"
        },
        "resourceId": {
          "example": "example",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
          "type": "string"
        },
        "resourceKind": {
          "$ref": "#/components/schemas/ResourceKind"
        },
        "scope": {
          "$ref": "#/components/schemas/PermissionScope"
        }
      },
      "required": [
        "scope"
      ],
      "type": "object"
    },
    "ProblemDetails": {
      "example": {
        "code": "example",
        "detail": "example",
        "errors": [
          {
            "code": "example",
            "detail": "example",
            "field": "example"
          }
        ],
        "instance": "example",
        "requestId": "example",
        "status": 1,
        "title": "example",
        "type": "example"
      },
      "properties": {
        "code": {
          "example": "example",
          "type": "string"
        },
        "detail": {
          "example": "example",
          "type": "string"
        },
        "errors": {
          "example": [
            {
              "code": "example",
              "detail": "example",
              "field": "example"
            }
          ],
          "items": {
            "$ref": "#/components/schemas/ProblemFieldError"
          },
          "type": "array"
        },
        "instance": {
          "example": "example",
          "type": "string"
        },
        "requestId": {
          "example": "example",
          "type": "string"
        },
        "status": {
          "example": 1,
          "format": "int32",
          "type": "integer"
        },
        "title": {
          "example": "example",
          "type": "string"
        },
        "type": {
          "example": "example",
          "type": "string"
        }
      },
      "required": [
        "type",
        "title",
        "status",
        "detail",
        "instance",
        "code",
        "requestId",
        "errors"
      ],
      "type": "object"
    },
    "ProblemFieldError": {
      "example": {
        "code": "example",
        "detail": "example",
        "field": "example"
      },
      "properties": {
        "code": {
          "example": "example",
          "type": "string"
        },
        "detail": {
          "example": "example",
          "type": "string"
        },
        "field": {
          "example": "example",
          "type": "string"
        }
      },
      "required": [
        "field",
        "code",
        "detail"
      ],
      "type": "object"
    },
    "ResourceKind": {
      "enum": [
        "project",
        "connection",
        "source",
        "model",
        "semantic_model",
        "pipeline",
        "dashboard"
      ],
      "example": "project",
      "type": "string"
    }
  }
}
