---
title: "Create connection for OAuth provider"
method: POST
path: "/oauth_providers/create"
tags: ["Oauth Providers"]
---

# Create connection for OAuth provider

`POST /oauth_providers/create`

Used to create a connection for an OAuth provider.
After receiving the response, the customer will be redirected to `return_to` URL.

Mobile clients receive a `connection_secret` parameter in the `return_to` URL if the connection was successfully connected and an `error_message` parameter if the connection failed to connect for some reason.

## Request body

- OauthConnectRequestBody
  - `data` object, required
    - `customer_id` string, required — the `id` of the customer received from [customer create](#customers-create). This field is optional for ['app' authentication](/general/v5/#services_and_apps_authentication)
    - `country_code` string, required — the code of the country
    - `provider_code` string, required — the code of the provider
    - `consent` ConsentRequestBody, required
      - `scopes` string[], required — data to be allowed for fetching. The allowed values for this parameter must fall within the client's `allowed_fetch_scopes` and/or provider's `supported_fetch_scopes` restrictions. To change the client's allowed scopes, please <a href='https://www.saltedge.com/pages/contact' target="_blank">contact our Sales team</a>. <strong>Note:</strong> `account_details` scope covers both `accounts` and `accounts_without_balance` attempt's [fetch_scopes](#attempts).<br>
      - `from_date` string, date — date to be allowed for fetching the data from. This parameter is used when `scopes` parameter contains `transactions_details`. The allowed values for this parameter must be within exactly 365 days ago.
      - `to_date` string, date, nullable — date to be allowed for fetching the data until. The allowed values for this parameter must be equal or more than `from_date`.
      - `period_days` integer — determines the period the consent will be valid for. Defaults to `null` (limitless) or provider's `max_consent_days`. The allowed value for this parameter must not be higher than the provider's `max_consent_days`.
    - `attempt` AttemptRequestBody
      - `fetch_scopes` string[] — fetching mode. Defaults to [consent](#consents-object) scopes. The allowed values for this parameter must comply to the [consent](#consents-object) `scopes` restriction.
      - `from_date` string, date — date from which you want to fetch data for your connection. Defaults to [consent](#consents-object) `from_date`. The allowed values for this parameter must be within exactly 365 days ago and it should comply to the fetching period restrictions in the [consent](#consents-object).
      - `to_date` string, date — date until which you want to fetch data for your connection. Defaults to `null` (today). The allowed values for this parameter must be equal or more than `from_date` and less or equal than tomorrow. Also it should comply to the fetching period restrictions in the [consent](#consents-object).
      - `fetched_accounts_notify` boolean — whether Salt Edge should send a success callback after fetching accounts.
      - `custom_fields` object — a JSON object, which will be sent back on any of your callbacks.
      - `locale` string — the language of the Connect widget and of the returned error message(s) in the <a href='http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes' target="_blank">ISO 639-1</a> format. Possible values are: `bg`, `cz`, `de`, `en`, `es-MX`, `es`, `fi`, `fr`, `he`, `hr`, `hu`, `it`, `nl`, `pl`, `pt-BR`, `pt`, `ro`, `ru`, `si`, `sk`, `sv`, `tr`, `uk`, `zh-HK`(Traditional), `zh`(Simplified). Defaults to `en`.
      - `include_natures` string[], nullable — the natures of the accounts that need to be fetched. Check [accounts attributes](#accounts-attributes) for possible values. If `null`, all accounts will be fetched.
      - `customer_last_logged_at` string, date-time — the datetime when user was last active in your application
      - `exclude_accounts` string[] — array of [account `ids`](#accounts-list) which will not be fetched. Applied to `reconnect` and `refresh` atempts.
      - `store_credentials` boolean, required — whether the credentials should be stored on Salt Edge side
      - `unduplication_strategy` string — This parameter mandates how duplicated transactions are managed. Possible values include: `mark_as_pending`, `mark_as_duplicate`, `delete_transactions`. The default is set to `mark_as_pending`. The provided value remains unchanged until other value is sent on [connect_session/reconnect](/account_information/v5/#connections-reconnect) or [connect_session/refresh](/account_information/v5/#connections-refresh). - `mark_as_pending` - leaves identified duplicated transactions in `Pending` status for clients that establish connections with providers having a non-null `custom_pendings_period` - `mark_as_duplicate` - identifies transactions as duplicated and sets the `duplicated` flag to `true` - `delete_trasactions` - removes identified duplicated transactions
      - `user_present` boolean — whether the request was initiated by the end-user of your application. It is taken into account only for PSD2-compliant providers and used for `reconnect` and `refresh`.
      - `return_to` string — the URL the user will be redirected to, defaults to client's home URL. If the provider has `api` mode and interactive `true` then this field is `mandatory`.
    - `daily_refresh` boolean — whether the connection should be automatically refreshed by Salt Edge.
    - `return_connection_id` boolean — whether to append `connection_id` to `return_to` URL.
    - `categorization` 'none' | 'personal' | 'business' — the type of categorization applied.
    - `include_fake_providers` boolean — if sent as `true`, the customers of [live](/general/v5/#live) clients will be able to connect [fake providers](#providers-fake).

## Response `200`

OK

- OauthConnectResponse
  - `data` object, required
    - `connection_id` string — `id` of the connection
    - `connection_secret` string
    - `attempt_id` string — `id` of the attempt
    - `token` string
    - `expires_at` string, date-time
    - `redirect_url` string

## Other responses

- `400` — The passed `from_date` - `to_date` interval is out of consent `from_date` - `to_date` range
- `404` — A customer with such `customer_id` could not be found
- `406` — Invalid consent period_days value or not allowed by provider

---

[API](https://skmtc.net/saltedge/apis/salt-edge-account-information-api.md) · [All operations](https://skmtc.net/saltedge/apis/salt-edge-account-information-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/saltedge/salt-edge-account-information-api/versions/f18f4f36d0b3/schema)
