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

# Request Sync

> Manually request to sync the current connections data.

By default, Terminal will sync all connections where `syncMode = automatic` on a regular cadence. For customers that may not need a fleet's data to be kept up to date and want to reduce their active tracked trucks, you can set `syncMode = manual` and invoke this endpoint when you want to sync data.

If you're wondering if this is relevent to your use case then feel free to reach out and we'd be happy to assist.


## OpenAPI

````yaml POST /syncs
openapi: 3.1.0
info:
  title: Terminal Telematics API
  description: >-
    Terminal is a unified API that makes it easy to integrate with the leading
    telematics service providers.
  version: '0.0'
  contact:
    name: Terminal
    email: connect@withterminal.com
    url: https://www.withterminal.com
servers:
  - url: https://api.withterminal.com/tsp/v1
    description: Production
  - url: https://api.sandbox.withterminal.com/tsp/v1
    description: Sandbox
security:
  - Authorization: []
tags:
  - name: Authentication
  - name: Connections
  - name: Data Management
  - name: Drivers
  - name: Groups
  - name: Hours of Service
  - name: IFTA
  - name: Issues
  - name: Link
  - name: Providers
  - name: Safety
  - name: Trailers
  - name: Vehicles
  - name: Vehicle Utilization
  - name: Webhook Events
paths:
  /syncs:
    parameters: []
    post:
      tags:
        - Data Management
      summary: Request Sync
      description: >-
        Manually request to sync the current connections data.


        By default, Terminal will sync all connections where `syncMode =
        automatic` on a regular cadence. For customers that may not need a
        fleet's data to be kept up to date and want to reduce their active
        tracked trucks, you can set `syncMode = manual` and invoke this endpoint
        when you want to sync data.


        If you're wondering if this is relevent to your use case then feel free
        to reach out and we'd be happy to assist.
      operationId: requestSync
      parameters:
        - $ref: '#/components/parameters/ConnectionToken'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              description: >-
                How to sync the data. If `startFrom` is not provided, it will
                either sync from the last time a sync was requested or `now` if
                the connection has no sync history. Can also provide `days`
                instead of `startFrom` and it will be converted to a date and
                used in place of `startFrom`.
              properties:
                startFrom:
                  $ref: '#/components/schemas/ISODateTime'
                  description: >-
                    When to start syncing from. If `startFrom` is not provided,
                    it will either sync from the last time a sync was requested
                    or `now` if the connection has no sync history.
                days:
                  type: number
                  description: >-
                    How many days of history to sync from `now`. Will be
                    converted to a date and used in place of `startFrom`
                providerRequests:
                  type: array
                  description: >-
                    Request additional information from the provider for this
                    sync.
                  example:
                    - type: historical_files
                  items:
                    $ref: '#/components/schemas/SyncProviderRequestType'
              example:
                days: 7
        description: ''
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sync'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '410':
          $ref: '#/components/responses/GoneError'
        '429':
          $ref: '#/components/responses/TooManyRequestsError'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '504':
          $ref: '#/components/responses/GatewayTimeoutError'
components:
  parameters:
    ConnectionToken:
      name: Connection-Token
      in: header
      required: true
      schema:
        type: string
        example: con_tkn_22vUhkC6tgre4kwaYfUkCDA1rzn6eyb4
        pattern: ^con_tkn_\S+$
      description: >-
        The token returned when a user authenticated their account. This
        authorizes access to a specific account.
  schemas:
    ISODateTime:
      title: ISODateTime
      type: string
      format: date-time
      example: '2021-01-06T03:24:53.000Z'
      description: '[ISO 8601](https://www.w3.org/TR/NOTE-datetime) date'
    SyncProviderRequestType:
      title: Sync Provider Request Type
      type: string
      enum:
        - historical_files
        - provision_credentials
    Sync:
      title: Sync
      type: object
      x-model-category: platform
      properties:
        id:
          $ref: '#/components/schemas/SyncId'
        status:
          $ref: '#/components/schemas/SyncStatus'
        failureReason:
          type: string
          description: If the sync failed, this will contain the reason
          example: Reason for failure if sync status is 'failed'
        progress:
          $ref: '#/components/schemas/Percentage'
          description: Current sync progress as a percentage between 0 and 100.
        issues:
          type: array
          description: >-
            Issues are problems encountered with a connection that did not
            result in a failed sync but may require manual intervention. You can
            see the issues for a given sync by providing `issues` to the
            `expand` parameter.
          items:
            $ref: '#/components/schemas/ExpandableIssue'
        startFrom:
          $ref: '#/components/schemas/ISODateTime'
          description: >-
            The earliest records to sync for those based on time (ex: historical
            locations and stats)
        requestedAt:
          $ref: '#/components/schemas/ISODateTime'
        completedAt:
          $ref: '#/components/schemas/ISODateTime'
        attempts:
          type: number
          example: 1
        providerRequests:
          type: array
          description: >-
            Provider requests attached to this sync. When non-empty, the sync is
            waiting on an out-of-band step on the provider's side (e.g. the
            provider manually delivering historical files, or credentials being
            provisioned) and may legitimately stay in progress for an extended
            period.
          example:
            - historical_files
          items:
            $ref: '#/components/schemas/SyncProviderRequestType'
      required:
        - id
        - status
        - requestedAt
      x-description: >-
        An object containing the state of a sync job. This can be polled after
        connection linking to know when data is available for ingestion.
    SyncId:
      title: SyncId
      type: string
      format: ulid
      pattern: ^sync_[0-9A-HJKMNP-TV-Z]{26}$
      example: sync_01GV12VR4DJP70GD1ZBK0SDWFH
    SyncStatus:
      title: SyncStatus
      type: string
      description: The status of the sync
      example: completed
      enum:
        - requested
        - in_progress
        - completed
        - failed
    Percentage:
      title: Percentage
      type: number
      description: Percentage value between 0 and 100, rounded to 2 decimal places.
      example: 85
      minimum: 0
      maximum: 100
    ExpandableIssue:
      title: ExpandableIssue
      example: isu_01D8ZQFGHVJ858NBF2Q7DV9MNC
      oneOf:
        - $ref: '#/components/schemas/IssueId'
        - $ref: '#/components/schemas/ExpandedIssue'
    ErrorPathDetail:
      title: ErrorPathDetail
      type: object
      properties:
        message:
          type: string
          example: '''vehicleId'' property must be a valid ulid'
        path:
          type: string
          example: '{requestQuery}.vehicleId'
        suggestion:
          type: string
          example: Please ensure you submit a valid 'vehicleId' property
        context:
          type: object
      required:
        - message
        - path
    IssueId:
      title: IssueId
      type: string
      format: ulid
      pattern: ^isu_[0-9A-HJKMNP-TV-Z]{26}$
      example: isu_01D8ZQFGHVJ858NBF2Q7DV9MNC
    ExpandedIssue:
      title: Expanded Issue
      type: object
      properties:
        id:
          $ref: '#/components/schemas/IssueId'
        resolutionType:
          $ref: '#/components/schemas/IssueResolutionType'
        documentationUrl:
          type: string
          format: uri
          description: Direct link to the resolution guide for this semantic issue.
          example: https://docs.withterminal.com/issues/permission-missing
        connection:
          $ref: '#/components/schemas/ConnectionId'
          description: The connection this issue belongs to.
        status:
          type: string
          enum:
            - ongoing
            - resolved
          example: ongoing
        error:
          type: object
          properties:
            code:
              $ref: '#/components/schemas/IssueCode'
            message:
              type: string
              example: >-
                Failed to ingest HOS Logs, missing permissions to access Duty
                Status Logs
          required:
            - code
            - message
        firstReportedAt:
          $ref: '#/components/schemas/ISODateTime'
        lastReportedAt:
          $ref: '#/components/schemas/ISODateTime'
      required:
        - id
        - connection
        - status
        - error
        - firstReportedAt
        - lastReportedAt
      x-description: >-
        An issue is a problem we encountered while ingesting data from a
        connection that may impact the quality or completeness of the data.
    IssueResolutionType:
      title: IssueResolutionType
      type: string
      description: How an issue is expected to be investigated or resolved.
      example: action_required
      enum:
        - action_required
        - automatic_retry
        - terminal_managed
        - known_limitation
        - investigation_required
    ConnectionId:
      title: ConnectionId
      type: string
      format: ulid
      example: conn_01GV12VR4DJP70GD1ZBK0SDWFH
    IssueCode:
      title: IssueCode
      type: string
      description: >-
        Stable semantic identifier for an Issue and its remediation workflow.
        Legacy values remain in the schema for source compatibility but are not
        emitted after migration.
      example: permission_missing
      enum:
        - missing_permissions
        - exceeded_retention_window
        - invalid_source_id
        - unknown_device_type
        - missing_safety_configuration
        - inaccessible_data
        - manually_disabled
        - permission_missing
        - oauth_scope_missing
        - subscription_required
        - retention_window_exceeded
        - provider_data_inaccessible
        - invalid_source_identifier
        - unsupported_device_type
        - stream_disabled
        - provider_provisioning_pending
        - provider_feature_not_enabled
        - missing_vehicle_identifier
        - missing_vehicle_assignment
        - provider_capability_not_supported
        - provider_source_data_invalid
        - provider_partially_configured
        - managed_poll_returned_no_data
        - managed_poll_failed
        - data_delayed
  responses:
    BadRequestError:
      description: Bad Request
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                enum:
                  - bad_request
              message:
                type: string
                example: Invalid request body
              detail:
                type: array
                items:
                  $ref: '#/components/schemas/ErrorPathDetail'
            required:
              - code
              - message
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                enum:
                  - unauthorized
              message:
                type: string
                example: Unauthorized Request
              detail:
                type: string
                example: Please ensure you have a valid API key
            required:
              - code
              - message
    ForbiddenError:
      description: Forbidden
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                enum:
                  - forbidden
              message:
                type: string
                example: Forbidden Request
              detail:
                type: string
                example: >-
                  Please ensure the connection token matches the resource you
                  are attempting to access.
            required:
              - code
              - message
    ConflictError:
      description: Conflict
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                enum:
                  - conflict
              message:
                type: string
                example: Sync already in progress
              detail:
                type: string
                example: 'Existing sync in progress: sync_01D8ZQFGHVJ858NBF2Q7DV9MNC'
            required:
              - code
              - message
    GoneError:
      description: Gone
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                enum:
                  - gone
                  - connection_deleted
                example: connection_deleted
              message:
                type: string
                example: Connection has been deleted and cannot be used
            required:
              - code
              - message
    TooManyRequestsError:
      description: Too Many Requests
      content:
        application/json:
          schema:
            type: object
            additionalProperties: true
            properties:
              code:
                enum:
                  - too_many_requests
              retryAfter:
                description: The number of seconds to wait before retrying the request
                type: integer
                example: 60
              message:
                type: string
                example: Too Many Requests
              detail:
                type: string
                example: You have exceeded your rate limit. Please try again later.
            required:
              - code
              - message
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                enum:
                  - internal_server_error
              message:
                type: string
                example: Internal Server Error
              detail:
                type: string
                example: Something went wrong
            required:
              - code
              - message
    GatewayTimeoutError:
      description: Gateway Timeout Error
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                enum:
                  - gateway_timeout
                  - provider_timeout
                description: >-
                  `provider_timeout` means the telematics provider did not
                  respond in time, or responded too slowly to finish the request
                  (for example, while paginating). Retry later or narrow the
                  request, for example with a shorter time range or smaller
                  `limit`. `gateway_timeout` means Terminal could not finish the
                  request in time for another reason.
              message:
                type: string
                example: Gateway Timeout
            required:
              - code
              - message
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer

````

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