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

# Claim GitHub installations from an OAuth code

> Exchanges the OAuth code GitHub redirected back with for the caller's GitHub identity, records the GitHub App installations that identity reaches as the caller's, and returns the caller's GitHub status.

Use this tool when you need to:
- Finish connecting GitHub once the install or authorize redirect hands the caller a code and state
- Renew the caller's GitHub credential and re-sync their installations with a fresh code and state from getGithubAuthorizeUrl

Examples:
- POST /github/installations/claim {"code": "9b2f61c0d4e8a7b35c1e", "state": "MTc2MTQ3MjAwMHxEdi1CQkFFQ180SUFBUkFCRUFBQVpfLUNBQUlHYzNSeWFXNW58bP3xQ2"}

Hints:
- code and state are required non-empty strings (the schema answers 422 otherwise): code is GitHub's single-use OAuth code, and state the one getGithubInstallUrl or getGithubAuthorizeUrl signed for the caller, valid for 30 minutes.
- GitHub is read in full before anything is written. The caller's installation links then become exactly the installations GitHub lists for the code's GitHub user, links to any others are removed, and a user who reaches none still answers connected with an empty installations list.
- Returns the IntegrationStatus, kind connected, with details vendor github: identity (github_user_id, login) and installations (installation_id, account_login, account_type, connected_at, repository_administration, permissions_url), most recently connected first.
- Use getGithubAuthorizeUrl instead to mint a fresh code and state after 403 github_claim_unverified or a code GitHub refused (422), and getGithubStatus to read the connection without claiming.
- Any signed-in user, for their own account; through a platform API key pinned to an org where the caller is a viewer or billing member it is refused with 403 org_role_insufficient, and an agent host's grant with 403 agent_host_route_not_allowed.
- Refused with 403 github_claim_unverified when the state does not verify (expired, altered or not signed by Aether) or binds another user, 422 for a code GitHub does not accept (spent or expired), 409 github_identity_mismatch when Aether holds another GitHub account for the caller (disconnectGithub first), 409 without a domain code while an installation the user reaches is being uninstalled (retry in a minute), 403 for a banned account, 403 account_deleting while the caller's account is being deleted, 502 when GitHub fails to answer or lists an invalid installation, and 503 on a deployment without the GitHub App.



## OpenAPI

````yaml api-reference/openapi.json POST /github/installations/claim
openapi: 3.1.0
info:
  title: Aether API
  version: 0.1.0
servers:
  - url: https://api.runaether.dev
security:
  - bearerAuth: []
paths:
  /github/installations/claim:
    post:
      tags:
        - github
      summary: Claim GitHub installations from an OAuth code
      description: >-
        Exchanges the OAuth code GitHub redirected back with for the caller's
        GitHub identity, records the GitHub App installations that identity
        reaches as the caller's, and returns the caller's GitHub status.


        Use this tool when you need to:

        - Finish connecting GitHub once the install or authorize redirect hands
        the caller a code and state

        - Renew the caller's GitHub credential and re-sync their installations
        with a fresh code and state from getGithubAuthorizeUrl


        Examples:

        - POST /github/installations/claim {"code": "9b2f61c0d4e8a7b35c1e",
        "state":
        "MTc2MTQ3MjAwMHxEdi1CQkFFQ180SUFBUkFCRUFBQVpfLUNBQUlHYzNSeWFXNW58bP3xQ2"}


        Hints:

        - code and state are required non-empty strings (the schema answers 422
        otherwise): code is GitHub's single-use OAuth code, and state the one
        getGithubInstallUrl or getGithubAuthorizeUrl signed for the caller,
        valid for 30 minutes.

        - GitHub is read in full before anything is written. The caller's
        installation links then become exactly the installations GitHub lists
        for the code's GitHub user, links to any others are removed, and a user
        who reaches none still answers connected with an empty installations
        list.

        - Returns the IntegrationStatus, kind connected, with details vendor
        github: identity (github_user_id, login) and installations
        (installation_id, account_login, account_type, connected_at,
        repository_administration, permissions_url), most recently connected
        first.

        - Use getGithubAuthorizeUrl instead to mint a fresh code and state after
        403 github_claim_unverified or a code GitHub refused (422), and
        getGithubStatus to read the connection without claiming.

        - Any signed-in user, for their own account; through a platform API key
        pinned to an org where the caller is a viewer or billing member it is
        refused with 403 org_role_insufficient, and an agent host's grant with
        403 agent_host_route_not_allowed.

        - Refused with 403 github_claim_unverified when the state does not
        verify (expired, altered or not signed by Aether) or binds another user,
        422 for a code GitHub does not accept (spent or expired), 409
        github_identity_mismatch when Aether holds another GitHub account for
        the caller (disconnectGithub first), 409 without a domain code while an
        installation the user reaches is being uninstalled (retry in a minute),
        403 for a banned account, 403 account_deleting while the caller's
        account is being deleted, 502 when GitHub fails to answer or lists an
        invalid installation, and 503 on a deployment without the GitHub App.
      operationId: claimGithubInstallations
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GitHubClaimInput'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IntegrationStatus'
          description: OK
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/GithubErrorResponse'
                  - $ref: '#/components/schemas/OrgAuthorizationErrorResponse'
          description: Forbidden
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubErrorResponse'
          description: Conflict
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubErrorResponse'
          description: Internal Server Error
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubErrorResponse'
          description: Bad Gateway
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GithubErrorResponse'
          description: Service Unavailable
components:
  schemas:
    GitHubClaimInput:
      additionalProperties: false
      properties:
        code:
          minLength: 1
          type: string
        state:
          minLength: 1
          type: string
      required:
        - code
        - state
      type: object
    IntegrationStatus:
      discriminator:
        mapping:
          connected: '#/components/schemas/ConnectedIntegrationStatus'
          disconnected: '#/components/schemas/DisconnectedIntegrationStatus'
          reauthorization_required: '#/components/schemas/ReauthorizationRequiredIntegrationStatus'
          unavailable: '#/components/schemas/UnavailableIntegrationStatus'
        propertyName: kind
      oneOf:
        - $ref: '#/components/schemas/UnavailableIntegrationStatus'
        - $ref: '#/components/schemas/DisconnectedIntegrationStatus'
        - $ref: '#/components/schemas/ConnectedIntegrationStatus'
        - $ref: '#/components/schemas/ReauthorizationRequiredIntegrationStatus'
    GithubErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - account_deleting
            - bad_gateway
            - bad_request
            - conflict
            - control_forbidden
            - creator_github_access_missing
            - forbidden
            - gateway_timeout
            - github_claim_unverified
            - github_identity_mismatch
            - github_reconnect_required
            - github_ref_not_found
            - gone
            - internal_error
            - method_not_allowed
            - no_dispatch_target
            - not_acceptable
            - not_found
            - not_implemented
            - org_role_insufficient
            - org_suspended
            - payment_required
            - precondition_failed
            - project_archived
            - project_has_no_repository
            - project_repo_disconnected
            - project_repository_differs
            - push_file_too_large
            - push_rejected
            - push_secret_detected
            - rate_limited
            - repository_administration_not_granted
            - repository_already_connected
            - repository_create_forbidden
            - repository_create_rejected
            - repository_created_not_linked
            - repository_owner_not_caller
            - request_canceled
            - request_timeout
            - request_too_large
            - save_in_progress
            - save_requires_task_creator
            - service_unavailable
            - task_already_saved
            - task_backed_by_work_tree
            - task_bound_at_creation
            - task_branch_diverged
            - task_branch_is_default
            - task_branch_mismatch
            - task_branch_missing
            - task_creator_deleted
            - task_executing
            - task_file_too_large
            - task_has_no_commits
            - task_has_no_files
            - task_history_has_merges
            - task_is_child
            - task_not_started
            - task_rebase_in_progress
            - unauthenticated
            - unsupported_media_type
            - validation_failed
            - working_tree_dirty
            - workspace_gone
            - workspace_outdated
          minLength: 1
          type: string
        error:
          minLength: 1
          type: string
        errors:
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
      required:
        - error
        - code
      type: object
    OrgAuthorizationErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - org_membership_required
            - org_role_insufficient
            - org_suspended
            - account_deleting
            - agent_host_route_not_allowed
            - credential_kind_not_admitted
            - grant_scope_insufficient
          type: string
        error:
          minLength: 1
          type: string
      required:
        - error
        - code
      type: object
    ConnectedIntegrationStatus:
      additionalProperties: false
      properties:
        details:
          $ref: '#/components/schemas/IntegrationDetails'
        kind:
          enum:
            - connected
          type: string
      required:
        - kind
        - details
      type: object
    DisconnectedIntegrationStatus:
      additionalProperties: false
      properties:
        kind:
          enum:
            - disconnected
          type: string
      required:
        - kind
      type: object
    ReauthorizationRequiredIntegrationStatus:
      additionalProperties: false
      properties:
        details:
          $ref: '#/components/schemas/IntegrationDetails'
        kind:
          enum:
            - reauthorization_required
          type: string
      required:
        - kind
        - details
      type: object
    UnavailableIntegrationStatus:
      additionalProperties: false
      properties:
        kind:
          enum:
            - unavailable
          type: string
      required:
        - kind
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    IntegrationDetails:
      discriminator:
        mapping:
          github: '#/components/schemas/GitHubIntegrationDetails'
          linear: '#/components/schemas/LinearIntegrationDetails'
          sentry: '#/components/schemas/SentryIntegrationDetails'
          slack: '#/components/schemas/SlackIntegrationDetails'
        propertyName: vendor
      oneOf:
        - $ref: '#/components/schemas/GitHubIntegrationDetails'
        - $ref: '#/components/schemas/LinearIntegrationDetails'
        - $ref: '#/components/schemas/SlackIntegrationDetails'
        - $ref: '#/components/schemas/SentryIntegrationDetails'
    GitHubIntegrationDetails:
      additionalProperties: false
      properties:
        identity:
          $ref: '#/components/schemas/GitHubUserIdentity'
        installations:
          items:
            $ref: '#/components/schemas/GitHubInstallation'
          type: array
        vendor:
          enum:
            - github
          type: string
      required:
        - identity
        - installations
        - vendor
      type: object
    LinearIntegrationDetails:
      additionalProperties: false
      properties:
        default_actor_user_id:
          format: uuid
          type: string
        installed_by:
          format: uuid
          type: string
        organization_id:
          minLength: 1
          type: string
        organization_name:
          minLength: 1
          type: string
        vendor:
          enum:
            - linear
          type: string
      required:
        - default_actor_user_id
        - installed_by
        - organization_id
        - organization_name
        - vendor
      type: object
    SentryIntegrationDetails:
      additionalProperties: false
      properties:
        default_actor_user_id:
          format: uuid
          type: string
        installed_by:
          format: uuid
          type: string
        organization_id:
          minLength: 1
          type: string
        organization_slug:
          minLength: 1
          type: string
        vendor:
          enum:
            - sentry
          type: string
      required:
        - default_actor_user_id
        - installed_by
        - organization_id
        - organization_slug
        - vendor
      type: object
    SlackIntegrationDetails:
      additionalProperties: false
      properties:
        default_actor_user_id:
          format: uuid
          type: string
        dm_ready:
          type: boolean
        installed_by:
          format: uuid
          type: string
        needs_reconnect:
          type: boolean
        team_id:
          minLength: 1
          type: string
        team_name:
          minLength: 1
          type: string
        vendor:
          enum:
            - slack
          type: string
      required:
        - default_actor_user_id
        - dm_ready
        - installed_by
        - needs_reconnect
        - team_id
        - team_name
        - vendor
      type: object
    GitHubUserIdentity:
      additionalProperties: false
      properties:
        github_user_id:
          format: int64
          minimum: 1
          type: integer
        login:
          minLength: 1
          pattern: ^\S(?:.*\S)?$
          type: string
      required:
        - github_user_id
        - login
      type: object
    GitHubInstallation:
      additionalProperties: false
      properties:
        account_login:
          minLength: 1
          type: string
        account_type:
          minLength: 1
          type: string
        connected_at:
          format: date-time
          type: string
        installation_id:
          format: int64
          minimum: 1
          type: integer
        permissions_url:
          format: uri
          minLength: 1
          type: string
        repository_administration:
          type: boolean
      required:
        - installation_id
        - account_login
        - account_type
        - connected_at
        - repository_administration
        - permissions_url
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

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