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

# Import a connection (deprecated)

> Adds a connection for which you already have credentials. This endpoint is deprecated, use the /connections endpoint instead.

<Info>
  Requires an API key with the `environment:connections:create` scope. [Learn more about API key scopes](/reference/backend/http-api/api-keys#scopes).
</Info>

## When to use

Use this API endpoint to import existing access tokens into Nango. It is mostly meant for one-off bulk imports when onboarding Nango, or for migrating existing connections when a provider introduced changes to its auth flow.

If a connection with the same `connection_id` and `provider_config_key` already exists, the endpoint updates it with the provided credentials instead of creating a new one.

To trigger OAuth flows with Nango, use the [Nango frontend SDK](/reference/frontend/frontend-sdk).

## Request body

You can use this endpoint to import OAuth 2, OAuth 1, API Keys, and Basic auth credentials.

The required fields depend on the type of authentication of the *connections* you are trying to import.


## OpenAPI

````yaml POST /connection
openapi: 3.1.0
info:
  title: Nango API
  description: Nango API specs used to authorize & sync data with external APIs.
  version: 1.0.0
servers:
  - url: https://api.nango.dev
    description: Production server
  - url: http://localhost:3003
    description: Local server
security:
  - bearerAuth: []
externalDocs:
  url: https://nango.dev/docs/reference/backend/http-api/authentication
paths:
  /connection:
    post:
      summary: Add a connection (deprecated)
      description: >-
        Adds a connection for which you already have credentials. This endpoint
        is deprecated, use the /connections endpoint instead.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - provider_config_key
              properties:
                connection_id:
                  type: string
                  description: The connection ID used to create the connection.
                provider_config_key:
                  type: string
                  description: The integration ID that you created on Nango.
                access_token:
                  type: string
                  description: (OAuth 2, required) Existing access token.
                refresh_token:
                  type: string
                  description: (OAuth 2, optional) Pass the refresh token if you have it.
                expires_at:
                  type: string
                  format: date
                  description: (OAuth 2, optional) Safer and preferred.
                expires_in:
                  type: integer
                  description: (OAuth 2, optional) In seconds.
                no_expiration:
                  type: boolean
                  description: >-
                    (OAuth2, optional) If the provider gives access tokens that
                    don't expire, pass in `true` to avoid an import validation
                    error.
                oauth_client_id_override:
                  type: string
                  description: >-
                    (OAuth2, optional) Override the integration's OAuth client
                    id
                oauth_client_secret_override:
                  type: string
                  description: >-
                    (OAuth2, optional) Override the integration's OAuth client
                    secret
                oauth_token:
                  type: string
                  description: >-
                    (OAuth 1, required) The client token to be attached to the
                    connection.
                oauth_token_secret:
                  type: string
                  description: >-
                    (OAuth 1, required) The client token secret to be attached
                    to the connection.
                metadata:
                  type: object
                  description: >-
                    (OAuth, required for some APIs) Metadata to be attached to
                    the connection.
                connection_config:
                  type: object
                  description: >-
                    (OAuth, required for some APIs) Additional configuration to
                    be attached to the connection.
                username:
                  type: string
                  description: (Basic, required) username to be attached to the connection.
                password:
                  type: string
                  description: (Basic, required) password to be attached to the connection.
                api_key:
                  type: string
                  description: >-
                    (API Key, required) API key to be attached to the
                    connection.
      responses:
        '200':
          description: Successfully created an integrations
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: The secret key from your Nango environment.

````