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

# Attach connection



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/cerca/openapi.documented.yml post /agents/{agentId}/connections
openapi: 3.1.0
info:
  description: API-key accessible routes for Cerca agents.
  title: Cerca API
  version: 0.0.0
servers:
  - url: https://api.cerca.dev
security:
  - bearerAuth: []
paths:
  /agents/{agentId}/connections:
    post:
      tags:
        - Connections
      summary: Attach connection
      parameters:
        - schema:
            type: string
            minLength: 1
            example: agent_abc123
          required: true
          in: path
          name: agentId
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AttachConnectionRequest'
      responses:
        '201':
          description: Connection attached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttachedConnection'
        '400':
          description: Invalid runtime request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            Access denied or non-transient quota exceeded. Limit errors include
            a stable code field.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Runtime resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >-
            Transient capacity limit exceeded. Limit errors include a stable
            code field.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Required runtime dependency unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        default:
          description: Runtime error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Cerca from '@cerca-dev/sdk';


            const client = new Cerca({
              apiKey: process.env['CERCA_API_KEY'], // This is the default and can be omitted
            });


            const attachedConnection = await
            client.connections.attach('agent_abc123', {
              connectionId: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
            });


            console.log(attachedConnection);
        - lang: Python
          source: |-
            import os
            from cerca import Cerca

            client = Cerca(
                api_key=os.environ.get("CERCA_API_KEY"),  # This is the default and can be omitted
            )
            attached_connection = client.connections.attach(
                agent_id="agent_abc123",
                connection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
            )
            print(attached_connection)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/matrices/cerca-go\"\n\t\"github.com/matrices/cerca-go/option\"\n)\n\nfunc main() {\n\tclient := cercago.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tattachedConnection, err := client.Connections.Attach(\n\t\tcontext.TODO(),\n\t\t\"agent_abc123\",\n\t\tcercago.ConnectionAttachParams{\n\t\t\tConnectionID: cercago.F(\"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\"),\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", attachedConnection)\n}\n"
        - lang: Ruby
          source: >-
            require "cerca"


            cerca = Cerca::Client.new(api_key: "My API Key")


            attached_connection = cerca.connections.attach("agent_abc123",
            connection_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")


            puts(attached_connection)
        - lang: CLI
          source: |-
            cerca connections attach \
              --api-key 'My API Key' \
              --agent-id agent_abc123 \
              --connection-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e
components:
  schemas:
    AttachConnectionRequest:
      type: object
      properties:
        connectionId:
          type: string
          format: uuid
        metadata:
          $ref: '#/components/schemas/ToolConnectionMetadata'
      required:
        - connectionId
      additionalProperties:
        x-stainless-any: true
    AttachedConnection:
      allOf:
        - $ref: '#/components/schemas/PublicConnectionSummary'
        - type: object
          properties:
            attachedAt:
              type: string
            metadata:
              $ref: '#/components/schemas/ToolConnectionMetadata'
          required:
            - attachedAt
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
          description: Stable machine-readable error code when the API can provide one.
          example: MONTHLY_TOKEN_BUDGET_EXCEEDED
      required:
        - error
    ToolConnectionMetadata:
      type: object
      additionalProperties:
        type: string
    PublicConnectionSummary:
      type: object
      properties:
        accountLabel:
          type:
            - string
            - 'null'
        createdAt:
          type: string
        id:
          type: string
          format: uuid
        owner:
          $ref: '#/components/schemas/ConnectionOwner'
        provider:
          $ref: '#/components/schemas/CredentialProvider'
        scopes:
          type: array
          items:
            type: string
        type:
          $ref: '#/components/schemas/CredentialType'
        updatedAt:
          type: string
      required:
        - accountLabel
        - createdAt
        - id
        - owner
        - provider
        - scopes
        - type
        - updatedAt
    ConnectionOwner:
      oneOf:
        - type: object
          properties:
            type:
              type: string
              enum:
                - organization
              x-stainless-const: true
          required:
            - type
          additionalProperties: false
          title: OrganizationConnectionOwner
          x-stainless-variantName: OrganizationConnectionOwner
        - type: object
          properties:
            fleetId:
              type: string
              example: fleet_abc123
            type:
              type: string
              enum:
                - fleet
              x-stainless-const: true
          required:
            - fleetId
            - type
          additionalProperties: false
          title: FleetConnectionOwner
          x-stainless-variantName: FleetConnectionOwner
      description: >-
        Public owner for a reusable connection. Organization owners use the
        authenticated organization; fleet owners add a fleetId.
      discriminator:
        propertyName: type
    CredentialProvider:
      type: string
      enum:
        - google
        - github
        - slack
        - linear
        - notion
        - custom
        - webhook
    CredentialType:
      type: string
      enum:
        - oauth
        - api_key
  securitySchemes:
    bearerAuth:
      bearerFormat: Cerca API key
      scheme: bearer
      type: http

````