Phonic auth API

The auth API from Phonic — 2 operation(s) for auth.

OpenAPI Specification

phonic-auth-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: API Reference agents auth API
  version: 1.0.0
servers:
- url: https://api.phonic.ai/v1
  description: https://api.phonic.ai/v1
tags:
- name: auth
paths:
  /auth/session_token:
    post:
      operationId: create-session-token
      summary: Create Session Token
      description: Creates a short-lived session token that can be used to authenticate WebSocket connections. Session tokens are useful for client-side applications where you don't want to expose your API key.
      tags:
      - auth
      parameters:
      - name: Authorization
        in: header
        description: Bearer authentication header of the form `Bearer <PHONIC_API_KEY>`. Manage your API keys [here](https://phonic.co/api-keys).
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Success response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/auth_create_session_token_Response_200'
        '400':
          description: Invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '401':
          description: Unauthorized (authentication missing or invalid)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicError'
        '403':
          description: Forbidden (only API keys can create session tokens)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionTokenRequest'
  /auth/conversation_token:
    post:
      operationId: create-conversation-token
      summary: Create Conversation Token
      description: Creates a short-lived conversation token scoped to a specific agent. Conversation tokens are useful for client-side applications that start a conversation with a single agent without exposing your API key.
      tags:
      - auth
      parameters:
      - name: Authorization
        in: header
        description: Bearer authentication header of the form `Bearer <PHONIC_API_KEY>`. Manage your API keys [here](https://phonic.co/api-keys).
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Success response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/auth_create_conversation_token_Response_200'
        '400':
          description: Invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '401':
          description: Unauthorized (authentication missing or invalid)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicError'
        '403':
          description: Forbidden (only API keys can create conversation tokens)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicError'
        '404':
          description: Agent not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateConversationTokenRequest'
components:
  schemas:
    auth_create_conversation_token_Response_200:
      type: object
      properties:
        conversation_token:
          type: string
          description: The conversation token to use for authentication.
        expires_at:
          type: string
          format: date-time
          description: When the conversation token expires.
      required:
      - conversation_token
      - expires_at
      title: auth_create_conversation_token_Response_200
    ValidationError:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ValidationErrorError'
        param_errors:
          type: object
          additionalProperties:
            type: string
          description: Parameter-specific validation errors
      required:
      - error
      - param_errors
      title: ValidationError
    auth_create_session_token_Response_200:
      type: object
      properties:
        session_token:
          type: string
          description: The session token to use for authentication.
        expires_at:
          type: string
          format: date-time
          description: When the session token expires.
      required:
      - session_token
      - expires_at
      title: auth_create_session_token_Response_200
    ValidationErrorError:
      type: object
      properties:
        message:
          type: string
          description: Error message
      required:
      - message
      title: ValidationErrorError
    BasicError:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/BasicErrorError'
      title: BasicError
    BasicErrorError:
      type: object
      properties:
        message:
          type: string
          description: Error message
        code:
          type: string
          description: Error code
      required:
      - message
      title: BasicErrorError
    CreateSessionTokenRequest:
      type: object
      properties:
        ttl_seconds:
          type: integer
          default: 300
          description: Time-to-live for the session token in seconds.
      title: CreateSessionTokenRequest
    CreateConversationTokenRequest:
      type: object
      properties:
        agent_id:
          type: string
          description: ID of the agent the conversation token is scoped to.
        ttl_seconds:
          type: integer
          default: 30
          description: Time-to-live for the conversation token in seconds.
      required:
      - agent_id
      title: CreateConversationTokenRequest
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer authentication header of the form `Bearer <PHONIC_API_KEY>`. Manage your API keys [here](https://phonic.co/api-keys).