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

# Sync upstream

> Enqueue a sync for the repository upstream. Returns the sync, which the worker processes asynchronously. Read `repo.upstream.latest_sync`, fetch `GET /:repo/upstream/syncs/:syncId`, or list `GET /:repo/upstream/syncs` for status.

<Note>**Required scope:** `write`</Note>


## OpenAPI

````yaml /openapi.json post /{org}/{repo}/upstream/syncs
openapi: 3.1.0
info:
  title: Depot API
  description: Depot HTTP API v1
  version: 1.0.0
servers:
  - url: https://api.mesa.dev/v1
security:
  - apiKey: []
paths:
  /{org}/{repo}/upstream/syncs:
    post:
      tags:
        - Repo
      summary: Sync upstream
      description: >-
        Enqueue a sync for the repository upstream. Returns the sync, which the
        worker processes asynchronously. Read `repo.upstream.latest_sync`, fetch
        `GET /:repo/upstream/syncs/:syncId`, or list `GET /:repo/upstream/syncs`
        for status.
      operationId: syncUpstream
      parameters:
        - in: path
          name: org
          schema:
            type: string
            minLength: 1
          required: true
          description: Organization slug
        - in: path
          name: repo
          schema:
            type: string
            minLength: 1
          required: true
          description: Repository name
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                direction:
                  type: string
                  enum:
                    - pull
                    - push
                  description: Direction to sync between the repository and its upstream.
                ref_globs:
                  description: >-
                    Branch and tag glob filters for this sync. Omit to sync all
                    branches and tags.
                  anyOf:
                    - type: object
                      properties:
                        branches:
                          type: string
                        tags:
                          type: string
                      required:
                        - branches
                      additionalProperties: false
                    - type: object
                      properties:
                        branches:
                          type: string
                        tags:
                          type: string
                      required:
                        - tags
                      additionalProperties: false
              required:
                - direction
              additionalProperties: false
      responses:
        '201':
          description: Sync enqueued
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  repo_id:
                    type: string
                  direction:
                    type: string
                    enum:
                      - pull
                      - push
                  status:
                    type: string
                    enum:
                      - queued
                      - in_progress
                      - completed
                      - failed
                  attempt:
                    type: integer
                  ref_globs:
                    type: object
                    properties:
                      branches:
                        type: string
                      tags:
                        type: string
                    required:
                      - branches
                      - tags
                    additionalProperties: false
                  stats:
                    anyOf:
                      - type: object
                        properties:
                          refs:
                            type: array
                            items:
                              type: object
                              properties:
                                name:
                                  type: string
                                before:
                                  anyOf:
                                    - type: string
                                    - type: 'null'
                                after:
                                  type: string
                                outcome:
                                  type: string
                                  enum:
                                    - updated
                                    - unchanged
                                    - filtered
                                    - rejected
                              required:
                                - name
                                - before
                                - after
                                - outcome
                        required:
                          - refs
                      - type: 'null'
                  error:
                    anyOf:
                      - type: string
                      - type: 'null'
                  created_at:
                    type: string
                    format: date-time
                  started_at:
                    anyOf:
                      - type: string
                        format: date-time
                      - type: 'null'
                  finished_at:
                    anyOf:
                      - type: string
                        format: date-time
                      - type: 'null'
                required:
                  - id
                  - repo_id
                  - direction
                  - status
                  - attempt
                  - ref_globs
                  - stats
                  - error
                  - created_at
                  - started_at
                  - finished_at
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '406':
          description: Not acceptable
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
        '500':
          description: Internal error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                      trace_id:
                        description: >-
                          Support correlation id attached to 5xx responses;
                          quote it when reporting an issue
                        type: string
                    required:
                      - code
                      - message
                required:
                  - error
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: API Key

````