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

# Bulk Import

> Create or submit link bulk import via the Junction API. Requires authentication with your team API key.

<Note>
  If you are planning to migrate connections, please [chat with us through support channels](/home/getting-support).
  Link Migration endpoints are disabled by default.
</Note>

Import existing provider connections to your [Bring Your Own OAuth](/wearables/connecting-providers/bring-your-own-oauth/overview) application credentials.

Before migrating any connection through this endpoint, you must first
[configure your BYOO app credential](/wearables/connecting-providers/bring-your-own-oauth/overview#setting-up-your-oauth-credentials) for the data provider
on your Junction Team.

Note that these connections cannot be migrated:

1. Any connection that is bound to an OAuth application credential not in your possession.

2. Any connection that is not bound to the OAuth application credential set on your Junction Team.

### Asynchronous execution

The Bulk Import endpoint enqueues all connections you submitted to a persistent background operation. It then responds
*202 Accepted* immediately afterwards.

You can inspect the status of the resulting background operation through the [List Bulk Ops](/api-reference/link/list-bulk-ops) endpoint.

Optionally, you may opt into the `wait_for_completion` mode, which would respond with 200 OK only if the operation does complete within 20 seconds.
Otherwise, the endpoint responds 202 Accepted.

<Note>
  You can submit any number of — or even all — connections through the Bulk Import API within a short period of time. Enqueuing is fast and
  does not disrupt the progress of the background operation.
</Note>


## OpenAPI

````yaml POST /v2/link/bulk_import
openapi: 3.1.0
info:
  title: Junction API
  description: https://docs.junction.com/
  version: 0.4.483
servers:
  - url: https://api.us.junction.com
    x-fern-server-name: Production
  - url: https://api.eu.junction.com
    x-fern-server-name: ProductionEU
  - url: https://api.sandbox.us.junction.com
    x-fern-server-name: Sandbox
  - url: https://api.sandbox.eu.junction.com
    x-fern-server-name: SandboxEU
security:
  - apiKeyAuth: []
paths:
  /v2/link/bulk_import:
    post:
      tags:
        - link
      summary: Bulk Import Connections
      operationId: bulk_import_connections_v2_link_bulk_import_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkImportConnectionsBody'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkImportConnectionsResponse'
        '202':
          description: Accepted
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    BulkImportConnectionsBody:
      properties:
        provider:
          $ref: '#/components/schemas/OAuthProviders'
          description: ℹ️ This enum is non-exhaustive.
        connections:
          items:
            $ref: '#/components/schemas/ConnectionRecipe'
          type: array
          title: Connections
        wait_for_completion:
          type: boolean
          title: Wait For Completion
          description: >

            Whether or not the endpoint should wait for the Bulk Op to complete
            before responding.


            When `wait_for_completion` is enabled, the endpoint may respond 200
            OK if the Bulk Op takes less than 20 seconds to complete.


            Otherwise, the endpoint always responds with 202 Created once the
            submitted data have been enqueued successfully. You can use

            the [List Bulk
            Ops](https://docs.tryvital.io/api-reference/link/list-bulk-ops)
            endpoint to inspect the progress of the Bulk Op.
          default: false
      type: object
      required:
        - provider
        - connections
      title: BulkImportConnectionsBody
    BulkImportConnectionsResponse:
      properties:
        user_ids_imported:
          items:
            type: string
            format: uuid
          type: array
          title: User Ids Imported
        user_ids_failed:
          items:
            type: string
            format: uuid
          type: array
          title: User Ids Failed
      type: object
      required:
        - user_ids_imported
        - user_ids_failed
      title: BulkImportConnectionsResponse
    HTTPValidationError:
      properties:
        detail:
          title: Detail
      type: object
      title: HTTPValidationError
    OAuthProviders:
      type: string
      enum:
        - oura
        - fitbit
        - garmin
        - strava
        - wahoo
        - ihealth
        - withings
        - google_fit
        - dexcom_v3
        - polar
        - cronometer
        - omron
        - whoop_v2
        - my_fitness_pal_v2
        - ultrahuman
        - runkeeper
      title: OAuthProviders
      description: ℹ️ This enum is non-exhaustive.
    ConnectionRecipe:
      properties:
        user_id:
          type: string
          format: uuid
          title: User Id
          description: >-
            Vital User ID. The user must be created ahead of the bulk import
            operation.
        access_token:
          type: string
          title: Access Token
          description: |-
            * OAuth 2.0 providers (Fitbit, etc): The latest Access Token.
            * OAuth 1.0 providers (Garmin): The Access Token.
        refresh_token:
          type: string
          title: Refresh Token
          description: |-
            * OAuth 2.0 providers (Fitbit, etc): The latest Refresh Token.
            * OAuth 1.0 providers (Garmin): The Token Secret.
        provider_id:
          type: string
          title: Provider Id
          description: |-
            User ID of the data provider.

            * Fitbit: 6-character Fitbit User ID 
            * Garmin: 36-character Garmin User ID
        expires_at:
          type: integer
          title: Expires At
          description: >-
            Access token expiry date, in terms of UNIX epoch seconds.


            * OAuth 2.0 providers (Fitbit, etc): The latest expiry date on your
            record.

            * OAuth 1.0 providers (Garmin): Use the constant value `2147483647`.
        oauth_scopes:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Oauth Scopes
          description: |-
            OAuth scopes of the data provider. Specify `null` if you do not
            have any scopes on record.

            * Fitbit: Has scopes
            * Garmin: No scope
      type: object
      required:
        - user_id
        - access_token
        - refresh_token
        - provider_id
        - expires_at
      title: ConnectionRecipe
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-vital-api-key
      description: Vital Team API Key

````