emolero's picture
Upload folder using huggingface_hub
ab74ec2 verified
|
Raw
History Blame Contribute Delete
26 kB

click-to-dial

openapi: 3.0.3

info:
  title: Click to Dial Service
  description: |
    The Click to Dial API allows API consumers to initiate and manage voice calls between two parties. The API processes call requests, sets up the call, and provides optional status notifications and call recording features. For specific details, please refer to [click-to-dial_API.md](/documentation/API_documentation/click-to-dial_API.md)

    # API functionality

    Based on the Click-to-Dial API, users can initiate and terminate click-to-call sessions. The Click-to-Call API has the following features:

    * The API consumer calls `POST /calls` to establish a call between the caller and the callee.
    * The API consumer calls `DELETE /calls/{callId}` to terminate an active call session.
    * Optionally, the API consumer can provide a callback URL (`sink`) to receive status notifications.

    # Authorization and authentication

    The "Camara Security and Interoperability Profile" provides details of how an API consumer requests an access token. Please refer to Identity and Consent Management (https://github.com/camaraproject/IdentityAndConsentManagement/) for the released version of the profile.

    The specific authorization flows to be used will be agreed upon during the onboarding process, happening between the API consumer and the API provider, taking into account the declared purpose for accessing the API, whilst also being subject to the prevailing legal framework dictated by local legislation.

    In cases where personal data is processed by the API and users can exercise their rights through mechanisms such as opt-in and/or opt-out, the use of three-legged access tokens is mandatory. This ensures that the API remains in compliance with privacy regulations, upholding the principles of transparency and user-centric privacy-by-design.

    # Further info and support

    (FAQs will be added in a later version of the documentation)

    # Additional CAMARA error responses

    The list of error codes in this API specification is not exhaustive. Therefore the API specification may not document some non-mandatory error statuses as indicated in `CAMARA API Design Guide`.
    Please refer to the `CAMARA_common.yaml` of the Commonalities Release associated to this API version for a complete list of error responses. The applicable Commonalities Release can be identified in the `API Readiness Checklist` document associated to this API version.

    As a specific rule, error `501 - NOT_IMPLEMENTED` can be only a possible error response if it is explicitly documented in the API.

  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: wip
  x-camara-commonalities: "0.7"

externalDocs:
  description: Product documentation at CAMARA
  url: https://github.com/camaraproject/ClickToDial

servers:
  - url: '{apiRoot}/click-to-dial/vwip'
    variables:
      apiRoot:
        default: http://localhost:9091
        description: API root, defined by the service provider, e.g. `api.example.com` or `api.example.com/somepath`

paths:
  /calls:
    post:
      tags:
        - Calls
      summary: Create a new Click to Dial call session
      description: |
        Creates a new Click to Dial call session between the caller and the callee.
      operationId: createCall
      security:
        - openId:
            - "click-to-dial:calls:create"
      parameters:
        - $ref: "#/components/parameters/x-correlator"
      requestBody:
        description: Create a Click to Dial call session.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCallRequest'
      responses:
        '201':
          description: Call created
          headers:
            x-correlator:
              $ref: '#/components/headers/x-correlator'
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Call"
        '400':
          $ref: '#/components/responses/Generic400'
        '401':
          $ref: '#/components/responses/Generic401'
        '403':
          $ref: '#/components/responses/Generic403'
        '409':
          $ref: '#/components/responses/Conflict409'
        '422':
          $ref: '#/components/responses/UnprocessableEntity422'
      callbacks:
        callStatusChanged:
          '{$request.body#/sink}':
            post:
              summary: Call status changed event
              description: |
                Event notification delivered to the sink URL when the call status
                changes (CloudEvents structured mode).
              requestBody:
                required: true
                content:
                  application/cloudevents+json:
                    schema:
                      $ref: '#/components/schemas/EventCTDStatusChanged'
                    examples:
                      CALL_STATUS_CHANGED_EXAMPLE:
                        $ref: '#/components/examples/CALL_STATUS_CHANGED_EXAMPLE'
              responses:
                '2XX':
                  description: Event successfully received by the sink.
  /calls/{callId}:
    get:
      tags:
        - Calls
      summary: Get call details
      description: Retrieve the details and current status of a Click to Dial call session.
      operationId: getCall
      security:
        - openId:
            - "click-to-dial:calls:read"
      parameters:
        - name: callId
          in: path
          required: true
          description: Unique call identifier
          schema:
            $ref: "#/components/schemas/callId"
        - $ref: "#/components/parameters/x-correlator"
      responses:
        '200':
          description: Call details
          headers:
            x-correlator:
              $ref: '#/components/headers/x-correlator'
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Call"
        '400':
          $ref: '#/components/responses/Generic400'
        '401':
          $ref: '#/components/responses/Generic401'
        '403':
          $ref: '#/components/responses/Generic403'
        '404':
          $ref: '#/components/responses/Generic404'

    delete:
      tags:
        - Calls
      summary: Terminate an active call
      description: |
        Terminates an active Click to Dial call session identified by the given callId.
      operationId: terminateCall
      security:
        - openId:
            - "click-to-dial:calls:delete"
      parameters:
        - name: callId
          in: path
          required: true
          description: Unique call identifier
          schema:
            $ref: "#/components/schemas/callId"
        - $ref: "#/components/parameters/x-correlator"
      responses:
        '204':
          description: Call terminated
          headers:
            x-correlator:
              $ref: '#/components/headers/x-correlator'
        '400':
          $ref: '#/components/responses/Generic400'
        '401':
          $ref: '#/components/responses/Generic401'
        '403':
          $ref: '#/components/responses/Generic403'
        '404':
          $ref: '#/components/responses/Generic404'
        '409':
          $ref: '#/components/responses/Conflict409'

  /calls/{callId}/recording:
    get:
      tags:
        - Recording
      summary: Get call recording
      description: Retrieve the recording associated with the given callId.
      operationId: getRecording
      security:
        - openId:
            - "click-to-dial:recordings:read"
      parameters:
        - name: callId
          in: path
          required: true
          description: Unique call identifier
          schema:
            $ref: "#/components/schemas/callId"
        - $ref: "#/components/parameters/x-correlator"
      responses:
        '200':
          description: Call recording resource
          headers:
            x-correlator:
              $ref: '#/components/headers/x-correlator'
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RecordingResource"
        '400':
          $ref: '#/components/responses/Generic400'
        '401':
          $ref: '#/components/responses/Generic401'
        '403':
          $ref: '#/components/responses/Generic403'
        '404':
          $ref: '#/components/responses/Generic404'

components:
  securitySchemes:
    openId:
      type: openIdConnect
      description: This API uses OpenID Connect for authentication and authorization.
      openIdConnectUrl: "https://example.com/.well-known/openid-configuration"
    notificationsBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: "{$request.body#/sinkCredential.credentialType}"

  headers:
    x-correlator:
      description: Correlation id for the different services
      schema:
        $ref: '#/components/schemas/XCorrelator'
      example: 'b4333c46-49c0-4f62-80d7-f0ef930f1c46'

  parameters:
    x-correlator:
      name: x-correlator
      in: header
      description: Correlation ID for the different services
      schema:
        $ref: '#/components/schemas/XCorrelator'
      example: 'b4333c46-49c0-4f62-80d7-f0ef930f1c46'

  schemas:
    XCorrelator:
      type: string
      pattern: '^[a-zA-Z0-9-_:;./<>{}]{0,256}$'
      description: Correlation id for tracking API calls across systems.

    callId:
      description: Call identification
      type: string
      example: 'call_550e8400-e29b-41d4-a716-446655440000'

    Call:
      description: Click to Dial call session resource
      type: object
      properties:
        callId:
          $ref: '#/components/schemas/callId'
        caller:
          $ref: '#/components/schemas/Caller'
        callee:
          $ref: '#/components/schemas/Callee'
        status:
          $ref: '#/components/schemas/status'
        createdAt:
          type: string
          format: date-time
          description: >
            Time when the call session was created.
            It must follow RFC 3339 and must have time zone.
            Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ.
        recordingEnabled:
          type: boolean
          description: Whether recording is enabled for this call.
      required:
        - callId
        - caller
        - callee
        - status
        - createdAt

    CreateCallRequest:
      description: Request to create a new Click to Dial call session
      type: object
      properties:
        caller:
          $ref: '#/components/schemas/Caller'
        callee:
          $ref: '#/components/schemas/Callee'
        sink:
          $ref: '#/components/schemas/sink'
        sinkCredential:
          $ref: '#/components/schemas/SinkCredential'
        recordingEnabled:
          type: boolean
          description: Whether call recording is enabled.
      required:
        - caller
        - callee
      example:
        caller:
          number: "+441234567890"
        callee:
          number: "+441234567891"
        sink: "https://endpoint.example.com/sink"
        sinkCredential:
          credentialType: ACCESSTOKEN
          accessToken: "ya29.A0AR...exampletoken"
          accessTokenExpiresUtc: "2026-01-01T00:00:00Z"
          accessTokenType: bearer
        recordingEnabled: true

    Caller:
      type: object
      properties:
        number:
          $ref: '#/components/schemas/PhoneNumber'
      required:
        - number

    Callee:
      type: object
      properties:
        number:
          $ref: '#/components/schemas/PhoneNumber'
      required:
        - number

    PhoneNumber:
      description: Phone number in E.164 format
      type: string
      pattern: '^\+[1-9]\d{1,14}$'
      example: '+12345678'

    sink:
      description: The address to which events shall be delivered, using the HTTP protocol.
      type: string
      format: uri
      example: "https://endpoint.example.com/sink"

    SinkCredential:
      description: A sink credential provides authentication or authorization information necessary to enable delivery of events to a target.
      type: object
      properties:
        credentialType:
          description: "The type of the credential. MUST be set to ACCESSTOKEN. Discriminator for credential subtypes."
          type: string
          enum:
            - ACCESSTOKEN
      discriminator:
        propertyName: credentialType
        mapping:
          ACCESSTOKEN: "#/components/schemas/AccessTokenCredential"
      required:
        - credentialType

    AccessTokenCredential:
      description: An access token credential.
      type: object
      allOf:
        - $ref: "#/components/schemas/SinkCredential"
        - type: object
          properties:
            credentialType:
              description: MUST be `ACCESSTOKEN` for this concrete credential schema.
              type: string
              enum:
                - ACCESSTOKEN
              example: ACCESSTOKEN
            accessToken:
              description: REQUIRED. An access token is a previously acquired token granting access to the target resource.
              type: string
            accessTokenExpiresUtc:
              type: string
              format: date-time
              description: >
                REQUIRED. An absolute UTC instant at which the token shall be considered expired.
                It must follow RFC 3339 and must have time zone.
                Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ.
            accessTokenType:
              description: REQUIRED. Type of the access token (See [OAuth 2.0](https://tools.ietf.org/html/rfc6749#section-7.1)).
              type: string
              enum:
                - bearer
          required:
            - credentialType
            - accessToken
            - accessTokenExpiresUtc
            - accessTokenType

    RecordingResource:
      description: Recording file for a Click to Dial call
      type: object
      properties:
        callId:
          $ref: '#/components/schemas/callId'
        content:
          type: string
          description: Base64 encoded audio content.
        contentType:
          type: string
          description: MIME type of the audio file.
          enum:
            - audio/wav
            - audio/mp3
            - audio/mpeg
            - audio/ogg
        generatedAt:
          type: string
          format: date-time
          description: >
            Timestamp when the recording was generated.
            It must follow RFC 3339 and must have time zone.
            Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ.
      required:
        - callId
        - content
        - contentType

    EventCTDStatusChanged:
      description: Common attributes of Click to Dial
      allOf:
        - $ref: "#/components/schemas/CloudEvent"
        - type: object
          properties:
            data:
              type: object
              description: Event details depending on the event type
              properties:
                callId:
                  $ref: '#/components/schemas/callId'
                caller:
                  $ref: '#/components/schemas/PhoneNumber'
                callee:
                  $ref: '#/components/schemas/PhoneNumber'
                status:
                  type: object
                  description: |
                    Call status object. `state` contains the current lifecycle state
                    and `reason` contains an optional disconnection reason when applicable.
                  properties:
                    state:
                      $ref: '#/components/schemas/status'
                    reason:
                      $ref: '#/components/schemas/reason'
                  required:
                    - state
                recordingResult:
                  $ref: '#/components/schemas/recordingResult'
                callDuration:
                  $ref: '#/components/schemas/callDuration'
                timestamp:
                  $ref: '#/components/schemas/timestamp'
              required:
                - callId
                - caller
                - callee
                - status
                - timestamp
          required:
            - data

    status:
      description: Call status
      type: string
      enum:
        - initiating
        - callingCaller
        - callingCallee
        - connected
        - disconnected
        - failed
      example: 'callingCaller'

    reason:
      description: This field indicates the disconnection reason. This field is mandatory when status is 'disconnected'.
      type: string
      enum:
        - hangUp
        - callerBusy
        - callerNoAnswer
        - callerFailure
        - callerAbandon
        - calleeBusy
        - calleeNoAnswer
        - calleeFailure
        - other
      example: 'hangUp'

    recordingResult:
      description: Recording Result. This field is mandatory when recording is enabled and the call is finished.
      type: string
      enum:
        - success
        - noRecord
        - fail
      example: 'success'

    callDuration:
      description: This field indicates the duration of the calls, in seconds. This field is mandatory when status is 'disconnected'.
      type: string
      example: '1600'

    timestamp:
      description: >
        Time stamp, UTC time.
        It must follow RFC 3339 and must have time zone.
        Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ.
      type: string
      format: date-time
      example: '2017-12-04T18:07:57Z'

    ErrorInfo:
      description: Common schema for errors
      type: object
      properties:
        status:
          type: integer
          description: HTTP status code returned along with this error response
        code:
          type: string
          description: Code given to this error
        message:
          type: string
          description: Detailed error description
      required:
        - status
        - code
        - message

    CloudEvent:
      description: |
        Event compliant with the CloudEvents specification.
        Note: Providers MUST deliver events using CloudEvents structured mode
        (HTTP header `Content-Type: application/cloudevents+json`).
      type: object
      properties:
        id:
          description: Identifier of this event, unique within the event `source` context. UUID is recommended.
          type: string
          format: uuid
          example: 83a0d986-0866-4f38-b8c0-fc65bfcda452
        source:
          description: |
            Identifies the context in which an event happened in the Provider implementation.
            It SHOULD be an absolute URI identifying the producer (for example the API root or producer instance).
          type: string
          format: uri-reference
          example: https://api.example.com/click-to-dial
        type:
          description: The type of the event. Use a vendor namespaced event type.
          type: string
          enum:
            - "org.camaraproject.click-to-dial.v0.status-changed"
        specversion:
          description: Version of the specification to which this event conforms (must be 1.0 if it conforms to cloudevents 1.0.2 version)
          type: string
          enum:
            - "1.0"
        datacontenttype:
          description: 'media-type that describes the event payload encoding, must be "application/json" for CAMARA APIs'
          type: string
          enum:
            - "application/json"
        data:
          description: Event notification details payload, which depends on the event type
          type: object
        time:
          description: |
            Timestamp of when the occurrence happened. It must follow RFC 3339
          type: string
          format: date-time
      discriminator:
        propertyName: 'type'
        mapping:
          org.camaraproject.click-to-dial.v0.status-changed: "#/components/schemas/EventCTDStatusChanged"
      required:
        - id
        - source
        - specversion
        - type
        - time

  responses:
    Generic400:
      description: Bad Request
      headers:
        x-correlator:
          $ref: "#/components/headers/x-correlator"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorInfo"
          examples:
            GENERIC_400_INVALID_ARGUMENT:
              description: Invalid Argument. Generic Syntax Exception
              value:
                status: 400
                code: INVALID_ARGUMENT
                message: Client specified an invalid argument, request body or query param.
            GENERIC_400_OUT_OF_RANGE:
              description: Out of Range. Specific syntax exception used when a given field has a pre-defined range or an invalid filter criteria combination is requested.
              value:
                status: 400
                code: OUT_OF_RANGE
                message: Client specified an invalid range.

    Generic401:
      description: Unauthorized
      headers:
        x-correlator:
          $ref: "#/components/headers/x-correlator"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorInfo"
          examples:
            GENERIC_401_UNAUTHENTICATED:
              description: Request cannot be authenticated.
              value:
                status: 401
                code: UNAUTHENTICATED
                message: Request not authenticated due to missing, invalid, or expired credentials.

    Generic403:
      description: Forbidden
      headers:
        x-correlator:
          $ref: "#/components/headers/x-correlator"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorInfo"
          examples:
            GENERIC_403_PERMISSION_DENIED:
              description: Permission denied. OAuth2 token access does not have the required scope or when the user fails operational security
              value:
                status: 403
                code: PERMISSION_DENIED
                message: Client does not have sufficient permissions to perform this action.
            GENERIC_403_INVALID_TOKEN_CONTEXT:
              description: Reflect some inconsistency between information in some field of the API and the related OAuth2 Token
              value:
                status: 403
                code: INVALID_TOKEN_CONTEXT
                message: "{{field}} is not consistent with access token."

    Generic404:
      description: Not found
      headers:
        x-correlator:
          $ref: "#/components/headers/x-correlator"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorInfo"
          examples:
            GENERIC_404_NOT_FOUND:
              description: Resource is not found
              value:
                status: 404
                code: NOT_FOUND
                message: The specified resource is not found.

    UnprocessableEntity422:
      description: Unprocessable Entity
      headers:
        x-correlator:
          $ref: "#/components/headers/x-correlator"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorInfo"
          examples:
            INVALID_PHONE_NUMBER:
              value:
                status: 422
                code: INVALID_PHONE_NUMBER
                message: Caller or callee number is not a valid E.164 phone number.
            SAME_CALLER_CALLEE:
              value:
                status: 422
                code: SAME_CALLER_CALLEE
                message: Caller and callee cannot be the same number.
            RECORDING_NOT_SUPPORTED:
              value:
                status: 422
                code: RECORDING_NOT_SUPPORTED
                message: Recording is not supported for this call.
            CALLER_NOT_AVAILABLE:
              value:
                status: 422
                code: CALLER_NOT_AVAILABLE
                message: Caller number is currently not reachable or not allowed to start a call.
            CALLEE_NOT_AVAILABLE:
              value:
                status: 422
                code: CALLEE_NOT_AVAILABLE
                message: Callee number is currently not reachable or not allowed to receive a call.


    Conflict409:
      description: Conflict
      headers:
        x-correlator:
          $ref: "#/components/headers/x-correlator"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorInfo"
          examples:
            CALL_ALREADY_ACTIVE:
              value:
                status: 409
                code: CALL_ALREADY_ACTIVE
                message: An active call already exists for the given caller and callee.

  examples:
    CALL_STATUS_CHANGED_EXAMPLE:
      description: |
        Call status changed. This example shows a CloudEvent delivered in structured
        mode (`Content-Type: application/cloudevents+json`). The `datacontenttype` describes
        the `data` payload.
      summary: Cloud event example for Click To Dial status change to disconnected due to hangUp
      value:
        id: 83a0d986-0866-4f38-b8c0-fc65bfcda452
        source: https://api.example.com/click-to-dial
        specversion: "1.0"
        datacontenttype: application/json
        type: org.camaraproject.click-to-dial.v0.status-changed
        time: 2021-12-12T00:00:00Z
        data:
          callId: "123e4567-e89b-12d3-a456-426614174000"
          caller: "+12345678"
          callee: "+12345678"
          status:
            state: "disconnected"
            reason: "hangUp"
          recordingResult: "success"
          callDuration: "1600"
          timestamp: "2017-12-04T18:07:57Z"