Opal Security tokens API

Operations related to API tokens

OpenAPI Specification

opal-security-tokens-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  contact:
    email: hello@opal.dev
    name: Opal Team
    url: https://www.opal.dev/
  description: The Opal API is a RESTful API that allows you to interact with the Opal Security platform programmatically.
  title: Opal access-rules tokens API
  version: '1.0'
servers:
- description: Production
  url: https://api.opal.dev/v1
tags:
- name: tokens
  description: Operations related to API tokens
paths:
  /tokens:
    get:
      summary: Get tokens
      description: Returns a list of first-party API tokens for your organization. Requires admin access.
      operationId: getTokens
      parameters:
      - description: The pagination cursor value.
        example: cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw
        explode: true
        in: query
        name: cursor
        required: false
        schema:
          type: string
        style: form
      - description: Number of results to return per page. Default is 200.
        example: 200
        explode: true
        in: query
        name: page_size
        required: false
        schema:
          type: integer
          maximum: 1000
        style: form
      - description: Filter by token IDs.
        explode: false
        in: query
        name: token_ids
        required: false
        schema:
          items:
            format: uuid
            type: string
          type: array
        style: form
      - description: Filter by user ID.
        example: 29827fb8-f2dd-4e80-9576-28e31e9934ac
        explode: true
        in: query
        name: user_id
        required: false
        schema:
          format: uuid
          type: string
        style: form
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedTokensList'
          description: A list of API tokens for your organization.
      security:
      - BearerAuth: []
      tags:
      - tokens
  /tokens/{token_id}:
    delete:
      summary: Delete token
      description: Deletes a first-party API token. Admins can delete any token. Non-admins can only delete their own tokens when the organization allows all users to create API tokens.
      operationId: deleteToken
      parameters:
      - description: The ID of the token to delete.
        example: f454d283-ca87-4a8a-bdbb-df212eca5353
        explode: false
        in: path
        name: token_id
        required: true
        schema:
          format: uuid
          type: string
        style: simple
      responses:
        '200':
          description: The token was successfully deleted.
        '403':
          description: Not authorized to delete this token.
        '404':
          description: Token not found.
      security:
      - BearerAuth: []
      tags:
      - tokens
components:
  schemas:
    PaginatedTokensList:
      example:
        next: cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw
        previous: cj1sZXdwd2VycWVtY29zZnNkc2NzUWxNMEUxTXk0ME16UXpNallsTWtJ
        results:
        - token_id: f454d283-ca87-4a8a-bdbb-df212eca5353
          created_at: 2022-01-23 04:56:07+00:00
          token_label: My API Token
          creator_user_id: d4a7d928-783e-4599-8ec6-088d635a5bcc
          user_id: d4a7d928-783e-4599-8ec6-088d635a5bcc
          access_level: READ_ONLY
      properties:
        next:
          description: The cursor with which to continue pagination if additional result pages exist.
          example: cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw
          nullable: true
          type: string
        previous:
          description: The cursor used to obtain the current result page.
          example: cj1sZXdwd2VycWVtY29zZnNkc2NzUWxNMEUxTXk0ME16UXpNallsTWtJ
          nullable: true
          type: string
        results:
          items:
            $ref: '#/components/schemas/Token'
          type: array
      required:
      - results
      type: object
    ApiAccessLevelEnum:
      description: The access level of an API token.
      enum:
      - READ_ONLY
      - FULL_ACCESS
      type: string
    Token:
      description: A first-party API token.
      example:
        token_id: f454d283-ca87-4a8a-bdbb-df212eca5353
        created_at: 2022-01-23 04:56:07+00:00
        token_preview: ab123
        token_label: My API Token
        creator_user_id: d4a7d928-783e-4599-8ec6-088d635a5bcc
        user_id: d4a7d928-783e-4599-8ec6-088d635a5bcc
        access_level: READ_ONLY
      properties:
        token_id:
          description: The ID of the API token.
          example: f454d283-ca87-4a8a-bdbb-df212eca5353
          format: uuid
          type: string
        created_at:
          description: The date and time the token was created.
          example: 2022-01-23 04:56:07+00:00
          format: date-time
          type: string
        token_label:
          description: A human-readable label for the token.
          example: My API Token
          type: string
        creator_user_id:
          description: The ID of the user who created the token.
          example: d4a7d928-783e-4599-8ec6-088d635a5bcc
          format: uuid
          type: string
        user_id:
          description: The ID of the user the token authenticates as.
          example: d4a7d928-783e-4599-8ec6-088d635a5bcc
          format: uuid
          type: string
        last_used_at:
          description: The date and time the token was last used.
          example: 2022-01-23 04:56:07+00:00
          format: date-time
          nullable: true
          type: string
        access_level:
          $ref: '#/components/schemas/ApiAccessLevelEnum'
        expires_at:
          description: The date and time the token expires.
          example: 2023-01-23 04:56:07+00:00
          format: date-time
          nullable: true
          type: string
      required:
      - token_id
      - created_at
      - token_label
      - creator_user_id
      - user_id
      - access_level
      type: object
  securitySchemes:
    BearerAuth:
      scheme: bearer
      type: http