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

# Get a token for a procedure step to use a connection

> Get the access token of a connection the run's own user made, such as Microsoft 365, for a procedure step to call that provider's API. A script step that declares `uses=connection:<provider>` gets one without calling this: Effective sets the variable in the step's sandbox and opens the provider's hosts.

Only the credential of a script step that declares the binding can call this, and only for the user the run acts for: never another member's connection, and never an organization-wide one. That user must have allowed the procedure to use the connection, which they do in the Effective web app. The token is the provider's own, so it can do whatever that user granted the connection.

Alpha: this operation may change or be removed without notice.



## OpenAPI

````yaml /openapi.json post /procedures/connection-tokens
openapi: 3.0.3
info:
  title: Effective API
  version: 2.0.0
  description: The public Effective REST API. Authenticate using an Effective API key.
servers:
  - url: https://api.canary.effectiveai.app/api/v2
    description: Canary
security:
  - bearerAuth: []
paths:
  /procedures/connection-tokens:
    post:
      tags:
        - Procedure runs
      summary: Get a token for a procedure step to use a connection
      description: >-
        Get the access token of a connection the run's own user made, such as
        Microsoft 365, for a procedure step to call that provider's API. A
        script step that declares `uses=connection:<provider>` gets one without
        calling this: Effective sets the variable in the step's sandbox and
        opens the provider's hosts.


        Only the credential of a script step that declares the binding can call
        this, and only for the user the run acts for: never another member's
        connection, and never an organization-wide one. That user must have
        allowed the procedure to use the connection, which they do in the
        Effective web app. The token is the provider's own, so it can do
        whatever that user granted the connection.


        Alpha: this operation may change or be removed without notice.
      operationId: createProcedureConnectionToken
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProcedureConnectionTokenCreate'
      responses:
        '200':
          description: The token, the variable a script reads it from, and its hosts.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProcedureConnectionToken'
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '403':
          description: >-
            Not the credential of a script step that declares this binding, the
            run acts for no user, or that user has not allowed the procedure to
            use the connection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '404':
          description: >-
            connection_not_found: the run’s user has no working connection of
            this kind.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '413':
          description: Request body is too large.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '503':
          description: Temporarily unavailable; retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
      security:
        - bearerAuth: []
components:
  schemas:
    ProcedureConnectionTokenCreate:
      type: object
      properties:
        provider:
          type: string
          enum:
            - microsoft
          description: Whose API the connection is for.
          example: microsoft
        alias:
          type: string
          pattern: ^[a-z][a-z0-9]{0,31}$
          description: >-
            The name of one of your organization’s own connections of this
            provider, in lower case. Omit for the default connection.
          example: finance
        expiresInSeconds:
          type: integer
          minimum: 60
          maximum: 4500
          description: >-
            How long the step needs the token. A stored token that ends sooner
            is refreshed first; the provider decides how long the new one lasts.
          example: 1200
      required:
        - provider
        - expiresInSeconds
      additionalProperties: false
    ProcedureConnectionToken:
      type: object
      properties:
        variable:
          type: string
          description: The environment variable a script reads the token from.
          example: MICROSOFT_GRAPH_ACCESS_TOKEN
        token:
          type: string
          description: The provider’s access token. Do not log it.
        hosts:
          type: array
          items:
            type: string
          description: >-
            The hosts a script reaches with the token. `*.` covers every
            subdomain.
          example:
            - graph.microsoft.com
            - '*.sharepoint.com'
      required:
        - variable
        - token
        - hosts
    V2CodedError:
      allOf:
        - $ref: '#/components/schemas/V2Error'
        - type: object
          properties:
            code:
              type: string
              minLength: 1
              description: Stable error code. Clients must tolerate unknown future codes.
            details:
              type: array
              items:
                type: object
                properties:
                  location:
                    type: string
                    enum:
                      - path
                      - query
                      - header
                      - body
                  path:
                    type: array
                    items:
                      type: string
                      maxLength: 64
                    maxItems: 12
                  code:
                    type: string
                    enum:
                      - required
                      - invalid_type
                      - invalid_value
                      - unknown_field
                  message:
                    type: string
                    minLength: 1
                    maxLength: 200
                required:
                  - location
                  - path
                  - code
                  - message
              minItems: 1
              maxItems: 20
              description: Bounded safe validation issues; may omit some invalid fields.
            requestId:
              type: string
              minLength: 1
              maxLength: 128
              description: >-
                Existing server correlation for this HTTP attempt, when
                available.
            dataset:
              type: string
              enum:
                - naic
                - osha
              description: Dataset needed for dataset_not_enabled.
            businessCode:
              type: string
              description: The rater’s own refusal code, for business_rejection.
            violations:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                    description: Authored or built-in constraint code
                  message:
                    type: string
                    description: Authored message for the failed constraint
                  path:
                    type: string
                    description: Input path of the offending value; empty for the request
                  value:
                    nullable: true
                    description: Offending input value, size-bounded by the runtime
                  constraint:
                    type: string
                    description: The constraint the value failed, as text
                  cite:
                    type: string
                    nullable: true
                    description: >-
                      Filing citation of the constraint, when the source cites
                      one
                required:
                  - code
                  - message
                  - path
                  - value
                  - constraint
                  - cite
                additionalProperties: false
              maxItems: 256
              description: >-
                Each input constraint the submission failed, for invalid_inputs
                and business_rejection.
            violationsTruncated:
              type: boolean
              description: >-
                True when the rater reported more violations than violations
                holds.
            executionId:
              type: string
              description: >-
                The recorded execution of a failed rating, for rater rating
                failures.
            accessUrl:
              type: string
              nullable: true
              format: uri
              description: Not currently returned.
          required:
            - code
    V2Error:
      type: object
      properties:
        error:
          type: string
          minLength: 1
          description: Human-readable explanation of the failure.
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Effective API key. Send Authorization: Bearer sk-eai-...'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.