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

# Create code providers

> Creates a new code providers.

Required API key scopes: any of `code-providers:write`, `code-providers:all`, `all:write`, `all:all`.



## OpenAPI

````yaml /coding-agent-api/openapi.json post /api/v1/code-providers
openapi: 3.1.0
info:
  title: Agen Coding Agent API
  version: 1.0.0
servers:
  - url: https://api.agenhq.com
security: []
paths:
  /api/v1/code-providers:
    post:
      tags:
        - Code Providers
      summary: Create code providers
      description: >-
        Creates a new code providers.


        Required API key scopes: any of `code-providers:write`,
        `code-providers:all`, `all:write`, `all:all`.
      operationId: createCode-providers
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CodeProvidersCreateRequest'
      responses:
        '201':
          description: A code provider connection configured for a workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodeProvidersCreateResponse'
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - statusCode
                  - code
                  - error
                  - message
                properties:
                  statusCode:
                    type: number
                  code:
                    type: string
                  error:
                    type: string
                  message:
                    type: string
        '401':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
        '403':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
      security:
        - apiKey: []
components:
  schemas:
    CodeProvidersCreateRequest:
      type: object
      required:
        - platform
        - name
        - base_url
        - metadata
      properties:
        platform:
          anyOf:
            - const: gitlab
              type: string
            - const: github
              type: string
        name:
          description: A human-readable name for the connected code provider account.
          type: string
        base_url:
          description: >-
            The base URL Agen should use to talk to the code hosting platform
            API.
          type: string
        metadata:
          anyOf:
            - type: object
              required:
                - type
                - token
              properties:
                type:
                  const: gitlab_personal_access_token
                  type: string
                token:
                  description: >-
                    The GitLab personal access token Agen should store securely
                    for this connection. Returned values are masked in API
                    responses.
                  type: string
            - type: object
              required:
                - type
                - token
              properties:
                type:
                  const: github_personal_access_token
                  type: string
                token:
                  description: >-
                    The GitHub personal access token Agen should store securely
                    for this connection. Returned values are masked in API
                    responses.
                  type: string
            - type: object
              required:
                - type
                - access_token
              properties:
                type:
                  const: github_oauth
                  type: string
                access_token:
                  description: >-
                    The GitHub OAuth access token Agen stores securely for this
                    connection. Returned values are masked in API responses.
                  type: string
                login:
                  type: string
                github_user_id:
                  type: number
      description: Fields used to create a code provider connection.
    CodeProvidersCreateResponse:
      type: object
      required:
        - id
        - workspace_id
        - user_id
        - platform
        - name
        - base_url
        - metadata
        - created_at
        - updated_at
      properties:
        id:
          readOnly: true
          description: The unique identifier of the code provider connection inside Agen.
          type: string
        workspace_id:
          readOnly: true
          description: The workspace that owns this code provider connection.
          type: string
        user_id:
          readOnly: true
          description: The user who connected this code provider account.
          type: string
        platform:
          anyOf:
            - const: gitlab
              type: string
            - const: github
              type: string
        name:
          description: A human-readable name for the connected code provider account.
          type: string
        base_url:
          description: >-
            The base URL Agen should use to talk to the code hosting platform
            API.
          type: string
        metadata:
          anyOf:
            - type: object
              required:
                - type
                - token
              properties:
                type:
                  const: gitlab_personal_access_token
                  type: string
                token:
                  description: >-
                    The GitLab personal access token Agen should store securely
                    for this connection. Returned values are masked in API
                    responses.
                  type: string
            - type: object
              required:
                - type
                - token
              properties:
                type:
                  const: github_personal_access_token
                  type: string
                token:
                  description: >-
                    The GitHub personal access token Agen should store securely
                    for this connection. Returned values are masked in API
                    responses.
                  type: string
            - type: object
              required:
                - type
                - access_token
              properties:
                type:
                  const: github_oauth
                  type: string
                access_token:
                  description: >-
                    The GitHub OAuth access token Agen stores securely for this
                    connection. Returned values are masked in API responses.
                  type: string
                login:
                  type: string
                github_user_id:
                  type: number
        created_at:
          format: date-time
          readOnly: true
          description: When the code provider connection was created in Agen.
          type: string
        updated_at:
          format: date-time
          readOnly: true
          description: When the code provider connection was last updated in Agen.
          type: string
      description: A code provider connection configured for a workspace.
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key

````