> ## 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.

# Create API key



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/cerca/openapi.documented.yml post /connections/api-keys
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:
  /connections/api-keys:
    post:
      tags:
        - Connections
      summary: Create API key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApiKeyConnectionRequest'
      responses:
        '201':
          description: Created reusable API-key connection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicConnectionSummary'
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Not authorized for this connection owner.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Requested connection owner or connection was not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '415':
          description: Content-Type must be application/json.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Connection limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        default:
          description: 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 connection = await client.connections.create({
              apiKey: 'sk_live_...',
              owner: { type: 'organization' },
              provider: 'custom',
            });

            console.log(connection.id);
        - 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
            )
            connection = client.connections.create(
                api_key="sk_live_...",
                owner={
                    "type": "organization"
                },
                provider="custom",
            )
            print(connection.id)
        - 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\tconnection, err := client.Connections.New(context.TODO(), cercago.ConnectionNewParams{\n\t\tAPIKey: cercago.F(\"sk_live_...\"),\n\t\tOwner: cercago.F[cercago.ConnectionOwnerUnionParam](cercago.ConnectionOwnerOrganizationConnectionOwnerParam{\n\t\t\tType: cercago.F(cercago.ConnectionOwnerOrganizationConnectionOwnerTypeOrganization),\n\t\t}),\n\t\tProvider: cercago.F(\"custom\"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", connection.ID)\n}\n"
        - lang: Ruby
          source: >-
            require "cerca"


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


            connection = cerca.connections.create(api_key: "sk_live_...", owner:
            {type: :organization}, provider: "custom")


            puts(connection)
        - lang: CLI
          source: |-
            cerca connections create \
              --api-key 'My API Key' \
              --api-key sk_live_... \
              --owner '{type: organization}' \
              --provider custom
components:
  schemas:
    CreateApiKeyConnectionRequest:
      type: object
      properties:
        owner:
          $ref: '#/components/schemas/ConnectionOwner'
        provider:
          type: string
          example: custom
          description: Credential provider to store an API key for.
        apiKey:
          type: string
          example: sk_live_...
          description: API key secret. It is stored securely and is not returned.
        accountLabel:
          type: string
          description: Optional human-readable account label.
          example: primary
      required:
        - owner
        - provider
        - apiKey
      additionalProperties: false
    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
    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
    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

````