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

# Create CodeSource



## OpenAPI

````yaml https://api.ravion.com/openapi.yaml post /code-sources
openapi: 3.0.0
info:
  title: Ravion
  version: 0.0.0
servers:
  - url: https://api.ravion.com
security:
  - BearerAuth: []
tags:
  - name: Projects
  - name: Environments
  - name: Pipelines
  - name: PipelineRuns
  - name: TerraformResources
  - name: TerraformExecutionSummaries
  - name: PipelineStepExecutions
  - name: AwsCloudWatch
  - name: PipelineVersions
  - name: Organizations
  - name: Stacks
  - name: StackWorkspaces
  - name: Auth
  - name: OAuth
  - name: User
  - name: Health
  - name: Memberships
  - name: ServiceAccounts
  - name: AwsDefaultNetworks
  - name: AwsAccounts
  - name: ApiKeys
  - name: ExecutionEnvironments
  - name: ModuleDefinitions
  - name: ModuleVersions
  - name: ModuleInstances
  - name: DefaultValueDefinitions
  - name: DefaultValues
  - name: CodeSources
  - name: Github
  - name: Gitlab
  - name: Git
  - name: Values
  - name: Deployments
  - name: DeploymentResources
  - name: InfrastructureEvents
  - name: WebSocket
  - name: Describe
paths:
  /code-sources:
    post:
      tags:
        - CodeSources
      summary: Create CodeSource
      operationId: CreateCodeSource
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                data:
                  $ref: '#/components/schemas/CodeSource.CreateRequest'
              required:
                - data
              type: object
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                additionalProperties: false
                properties:
                  data:
                    $ref: '#/components/schemas/CodeSource'
                required:
                  - data
                type: object
          description: >-
            The request has succeeded and a new resource has been created as a
            result.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: The request is invalid or malformed.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: You are not authenticated
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: You do not have permission to access this resource.
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: Client error
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors.UserFacingErrorData'
          description: Server error
components:
  schemas:
    CodeSource.CreateRequest:
      description: Code source create request
      discriminator:
        mapping:
          GITHUB:
            $ref: '#/components/schemas/CodeSource.GithubCreateRequest'
          GITLAB:
            $ref: '#/components/schemas/CodeSource.GitlabCreateRequest'
          GITLAB_SELF_HOSTED:
            $ref: '#/components/schemas/CodeSource.GitlabSelfHostedCreateRequest'
        propertyName: type
      oneOf:
        - $ref: '#/components/schemas/CodeSource.GithubCreateRequest'
        - $ref: '#/components/schemas/CodeSource.GitlabCreateRequest'
        - $ref: '#/components/schemas/CodeSource.GitlabSelfHostedCreateRequest'
      type: object
    CodeSource:
      discriminator:
        mapping:
          GITHUB:
            $ref: '#/components/schemas/CodeSource.Github'
          GITLAB:
            $ref: '#/components/schemas/CodeSource.Gitlab'
          GITLAB_SELF_HOSTED:
            $ref: '#/components/schemas/CodeSource.GitlabSelfHosted'
        propertyName: type
      oneOf:
        - $ref: '#/components/schemas/CodeSource.Github'
        - $ref: '#/components/schemas/CodeSource.Gitlab'
        - $ref: '#/components/schemas/CodeSource.GitlabSelfHosted'
      type: object
    Errors.UserFacingErrorData:
      additionalProperties: false
      description: |-
        User-facing error presentation data.
        This is what the API returns to the frontend after formatting ErrorData
        using CEL templates from the error registry.

        Used for both:
        - Error fields on domain models (e.g., PipelineRun.error)
        - API error response bodies (HTTP 4xx/5xx responses)
      properties:
        action:
          allOf:
            - $ref: '#/components/schemas/Errors.Action'
          description: Optional action to help resolve the error
        code:
          description: Full error code, e.g., "Ravion:Pipeline:NOT_FOUND"
          type: string
        description:
          description: Additional description with more details
          type: string
        details:
          description: Structured details rendered as user-facing sections.
          items:
            $ref: '#/components/schemas/Errors.UserFacingErrorDetailSection'
          type: array
        isInternal:
          description: >-
            Indicates whether this error is internal (only set when
            ShowInternal=true).

            This allows SUPERADMINs to identify internal errors while viewing
            full details.
          type: boolean
        message:
          description: Main error message (required)
          type: string
        metadata:
          additionalProperties: {}
          description: >-
            Error params/metadata. Stripped for internal errors unless
            superadmin.
          type: object
        requestId:
          description: Request ID for correlating errors with server logs.
          type: string
      required:
        - code
        - message
      type: object
    CodeSource.GithubCreateRequest:
      additionalProperties: false
      description: Create request for GitHub repositories
      properties:
        githubInstallationId:
          description: GitHub installation ID
          minLength: 1
          type: string
        repoUrl:
          description: Git repository URL
          minLength: 1
          type: string
        type:
          enum:
            - GITHUB
          type: string
      required:
        - type
        - repoUrl
        - githubInstallationId
      type: object
    CodeSource.GitlabCreateRequest:
      additionalProperties: false
      description: Create request for GitLab.com repositories
      properties:
        gitlabThirdPartyAccountId:
          description: GitLab third-party account ID
          minLength: 1
          type: string
        repoUrl:
          description: Git repository URL
          minLength: 1
          type: string
        type:
          enum:
            - GITLAB
          type: string
      required:
        - type
        - repoUrl
        - gitlabThirdPartyAccountId
      type: object
    CodeSource.GitlabSelfHostedCreateRequest:
      additionalProperties: false
      description: Create request for self-hosted GitLab repositories
      properties:
        gitSelfHostedServerId:
          description: Git self-hosted server ID
          minLength: 1
          type: string
        gitlabThirdPartyAccountId:
          description: GitLab third-party account ID for OAuth
          minLength: 1
          type: string
        repoUrl:
          description: Git repository URL
          minLength: 1
          type: string
        type:
          enum:
            - GITLAB_SELF_HOSTED
          type: string
      required:
        - type
        - repoUrl
        - gitlabThirdPartyAccountId
        - gitSelfHostedServerId
      type: object
    CodeSource.Github:
      additionalProperties: false
      description: GitHub code source
      properties:
        accessLost:
          description: Whether sync found the auth no longer has access to this repository
          readOnly: true
          type: boolean
        auth:
          allOf:
            - $ref: '#/components/schemas/CodeSourceGithubAuth'
          description: Authentication details
          readOnly: true
        createdAt:
          allOf:
            - $ref: '#/components/schemas/UtcDateTime'
          readOnly: true
        defaultBranch:
          readOnly: true
          type: string
        gitRepositoryId:
          readOnly: true
          type: string
        id:
          readOnly: true
          type: string
        organizationId:
          readOnly: true
          type: string
        repoName:
          readOnly: true
          type: string
        repoUrl:
          readOnly: true
          type: string
        type:
          enum:
            - GITHUB
          type: string
        updatedAt:
          allOf:
            - $ref: '#/components/schemas/UtcDateTime'
          readOnly: true
        visibility:
          allOf:
            - $ref: '#/components/schemas/GitRepositoryVisibility'
          description: Repository visibility (public, private, or internal)
          readOnly: true
      required:
        - id
        - createdAt
        - updatedAt
        - organizationId
        - gitRepositoryId
        - repoUrl
        - repoName
        - defaultBranch
        - visibility
        - accessLost
        - type
        - auth
      type: object
    CodeSource.Gitlab:
      additionalProperties: false
      description: GitLab.com code source
      properties:
        accessLost:
          description: Whether sync found the auth no longer has access to this repository
          readOnly: true
          type: boolean
        auth:
          allOf:
            - $ref: '#/components/schemas/CodeSourceGitlabAuth'
          description: Authentication details
          readOnly: true
        createdAt:
          allOf:
            - $ref: '#/components/schemas/UtcDateTime'
          readOnly: true
        defaultBranch:
          readOnly: true
          type: string
        gitRepositoryId:
          readOnly: true
          type: string
        id:
          readOnly: true
          type: string
        organizationId:
          readOnly: true
          type: string
        repoName:
          readOnly: true
          type: string
        repoUrl:
          readOnly: true
          type: string
        type:
          enum:
            - GITLAB
          type: string
        updatedAt:
          allOf:
            - $ref: '#/components/schemas/UtcDateTime'
          readOnly: true
        visibility:
          allOf:
            - $ref: '#/components/schemas/GitRepositoryVisibility'
          description: Repository visibility (public, private, or internal)
          readOnly: true
      required:
        - id
        - createdAt
        - updatedAt
        - organizationId
        - gitRepositoryId
        - repoUrl
        - repoName
        - defaultBranch
        - visibility
        - accessLost
        - type
        - auth
      type: object
    CodeSource.GitlabSelfHosted:
      additionalProperties: false
      description: GitLab self-hosted code source
      properties:
        accessLost:
          description: Whether sync found the auth no longer has access to this repository
          readOnly: true
          type: boolean
        auth:
          allOf:
            - $ref: '#/components/schemas/CodeSourceGitlabSelfHostedAuth'
          description: Authentication details
          readOnly: true
        createdAt:
          allOf:
            - $ref: '#/components/schemas/UtcDateTime'
          readOnly: true
        defaultBranch:
          readOnly: true
          type: string
        gitRepositoryId:
          readOnly: true
          type: string
        id:
          readOnly: true
          type: string
        organizationId:
          readOnly: true
          type: string
        repoName:
          readOnly: true
          type: string
        repoUrl:
          readOnly: true
          type: string
        type:
          enum:
            - GITLAB_SELF_HOSTED
          type: string
        updatedAt:
          allOf:
            - $ref: '#/components/schemas/UtcDateTime'
          readOnly: true
        visibility:
          allOf:
            - $ref: '#/components/schemas/GitRepositoryVisibility'
          description: Repository visibility (public, private, or internal)
          readOnly: true
      required:
        - id
        - createdAt
        - updatedAt
        - organizationId
        - gitRepositoryId
        - repoUrl
        - repoName
        - defaultBranch
        - visibility
        - accessLost
        - type
        - auth
      type: object
    Errors.Action:
      additionalProperties: false
      description: Action to help user resolve the error
      properties:
        label:
          description: Button/link label text
          type: string
        url:
          description: URL to navigate to for resolution
          type: string
      required:
        - label
        - url
      type: object
    Errors.UserFacingErrorDetailSection:
      additionalProperties: false
      description: Structured user-facing error detail section.
      properties:
        items:
          description: List of detail values for this section.
          items:
            type: string
          type: array
        object:
          additionalProperties: {}
          description: Structured detail payload for object rendering.
          type: object
        render:
          description: Rendering hint for clients. Valid values are list or object.
          type: string
        title:
          description: Detail section title shown in the UI.
          type: string
      required:
        - title
        - render
      type: object
    CodeSourceGithubAuth:
      description: GitHub auth — either installation or public
      discriminator:
        mapping:
          installation:
            $ref: '#/components/schemas/CodeSourceGithubInstallationAuth'
          public:
            $ref: '#/components/schemas/CodeSourcePublicAuth'
        propertyName: kind
      oneOf:
        - $ref: '#/components/schemas/CodeSourceGithubInstallationAuth'
        - $ref: '#/components/schemas/CodeSourcePublicAuth'
      type: object
    UtcDateTime:
      description: UTC RFC3339 timestamp with a required Z suffix
      format: date-time
      pattern: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?Z$
      type: string
      x-go-type: apitypes.UTCDateTime
      x-go-type-import:
        name: apitypes
        path: ravion/api-go/pkg/apitypes
    GitRepositoryVisibility:
      description: Repository visibility
      enum:
        - PUBLIC
        - PRIVATE
        - INTERNAL
      type: string
    CodeSourceGitlabAuth:
      description: GitLab auth — either OAuth or public
      discriminator:
        mapping:
          oauth:
            $ref: '#/components/schemas/CodeSourceGitlabOAuthAuth'
          public:
            $ref: '#/components/schemas/CodeSourcePublicAuth'
        propertyName: kind
      oneOf:
        - $ref: '#/components/schemas/CodeSourceGitlabOAuthAuth'
        - $ref: '#/components/schemas/CodeSourcePublicAuth'
      type: object
    CodeSourceGitlabSelfHostedAuth:
      description: GitLab self-hosted auth — either OAuth or public
      discriminator:
        mapping:
          oauth:
            $ref: '#/components/schemas/CodeSourceGitlabSelfHostedOAuthAuth'
          public:
            $ref: '#/components/schemas/CodeSourcePublicAuth'
        propertyName: kind
      oneOf:
        - $ref: '#/components/schemas/CodeSourceGitlabSelfHostedOAuthAuth'
        - $ref: '#/components/schemas/CodeSourcePublicAuth'
      type: object
    CodeSourceGithubInstallationAuth:
      additionalProperties: false
      description: GitHub App installation auth
      properties:
        githubInstallationId:
          description: GitHub installation ID
          type: string
        kind:
          enum:
            - installation
          type: string
      required:
        - kind
        - githubInstallationId
      type: object
    CodeSourcePublicAuth:
      additionalProperties: false
      description: Public (unauthenticated) access
      properties:
        kind:
          enum:
            - public
          type: string
      required:
        - kind
      type: object
    CodeSourceGitlabOAuthAuth:
      additionalProperties: false
      description: GitLab OAuth auth
      properties:
        gitlabThirdPartyAccountId:
          description: GitLab third-party account ID for OAuth
          type: string
        kind:
          enum:
            - oauth
          type: string
      required:
        - kind
        - gitlabThirdPartyAccountId
      type: object
    CodeSourceGitlabSelfHostedOAuthAuth:
      additionalProperties: false
      description: GitLab self-hosted OAuth auth
      properties:
        gitSelfHostedServerId:
          description: Git self-hosted server ID
          type: string
        gitlabThirdPartyAccountId:
          description: GitLab third-party account ID for OAuth
          type: string
        kind:
          enum:
            - oauth
          type: string
      required:
        - kind
        - gitlabThirdPartyAccountId
        - gitSelfHostedServerId
      type: object
  securitySchemes:
    BearerAuth:
      scheme: Bearer
      type: http

````