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

# Import a credential

> This endpoint imports a credential into your account.

You'll **import a credential** in the event that you've authenticated a user with a provider outside of Sequin. For example, you might have your users authenticate to Stripe via an OAuth flow you control. You can then import that credential into Sequin.

Importing a credential is an **idempotent** operation. Sequin upserts credentials. So, if you attempt to import a credential for an existing Salesforce account, only one credential will be created.

## Request parameters

<ParamField body="name" type="string">
  A name for your credential.
</ParamField>

<ParamField body="properties" type="object" required>
  The credential properties for the provider.

  <Note>
    The `properties` parameter depend on the `kind` of credential you're importing. See [the list of possible values](/management-api/objects#credential-properties).
  </Note>
</ParamField>

<ParamField body="oauth_app_id" type="string" required>
  OAuth app to associate with the credential. Learn more about [the OAuth app object](/management-api/oauth-apps/list).

  Note that this OAuth app must have the same `client_id` and `client_secret` that you used to originally obtain the credential.
</ParamField>

<ParamField body="metadata" type="object">
  Metadata for the credential. This is a free-form object that you can use to store any additional information you want to associate with the credential.
</ParamField>

<RequestExample>
  ```shell cURL theme={null}
  curl --request POST \
    --url https://api.sequin.io/v1/credentials \
    --header 'Authorization: Bearer YOUR_API_TOKEN' \
    --header 'Content-Type: application/json' \
    --data '{
      "properties": {
        "kind": "stripe_key",
        "name": "Choam Stripe",
        "secret": "sk_live_7eC39HqLyjWDarjtT1zdp7dcasd",
        "test": false
      },
      "oauth_app_id": "8ff58ef0-d376-4ae8-b2e2-9f0206aa65b8",
      "metadata": { "custom_property": 42 }
    }'
  ```
</RequestExample>

## Response fields

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "id": "c906b4a4-0cda-4f46-bd80-255f570c195d",
    "provider": "stripe",
    "oauth_app_id": "8ff58ef0-d376-4ae8-b2e2-9f0206aa65b8",
    "oauth_app": {
      "name": "Arakkis - Stripe",
      "id": "8ff58ef0-d376-4ae8-b2e2-9f0206aa65b8"
      "client_id": "b9f074c939140210e8c231845bbe8b98",
      "client_secret": "**********",
      "metadata": {},
      "provider": "stripe",
      "created_at": "2024-02-20T02:10:52Z",
      "updated_at": "2024-02-20T02:10:52Z"

    },
    "properties": {
      "kind": "stripe_key",
      "name": "TEST ACCOUNT",
      "secret": "***********",
      "test": true
    },
    // The health field is coming soon
    "health": {
      "status": "error",
      "notes": [
        "We're receiving 401s from Stripe for this token. That usually means the token is expired or revoked. We've emailed the owner of this credential to let them know."
      ],
      "time": "2023-12-15 01:29:29"
    },
    "metadata": { "custom_property": 42 },
    "created_at": "2023-12-15 01:29:29",
    "updated_at": "2023-12-15 01:29:29"
  }
  ```
</ResponseExample>

<ResponseField name="id" type="string">
  ID of the credential.
</ResponseField>

<ResponseField name="provider" type="string">
  Provider of the credential (e.g. `github`, `stripe`, etc). See [the list of possible values](/management-api/objects#sync-providers).
</ResponseField>

<ResponseField name="kind" type="string">
  Kind of credential (e.g. `stripe_oauth`, `github`, etc). See [the list of possible values](/management-api/objects#credential-properties).
</ResponseField>

<ResponseField name="health" type="object">
  Status of the credential. Learn more about [the health object](/management-api/objects#health).
</ResponseField>

<ResponseField name="oauth_app" type="object">
  OAuth app associated to the credential. Learn more about [the OAuth app object](/management-api/oauth-apps/list).
</ResponseField>

<ResponseField name="properties" type="credential_properties">
  The properties for the credential. This field is polymorphic based on the credential kind. Learn more about [credential properties](/management-api/objects#credential-properties).
</ResponseField>

<ResponseField name="metadata" type="string">
  Metadata for the credential. This is a free-form object that you can use to store any additional information you want to associate with the credential.
</ResponseField>

<ResponseField name="created_at" type="string">
  Timestamp of when the credential was created, in ISO 8601 format.
</ResponseField>

<ResponseField name="updated_at" type="string">
  Timestamp of when the credential was last updated, in ISO 8601 format.
</ResponseField>
