---
title: "Create or replace an OAuth connection"
description: "Stores encrypted provider credentials for a workspace. For Lead Perfection, this accepts username/password/clientid/appkey and optionally apiBaseUrl."
---

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

Path: Channel Automation API › Integrations

`POST /api/oauth/connections`

Stores encrypted provider credentials for a workspace. For Lead Perfection, this accepts username/password/clientid/appkey and optionally apiBaseUrl.

## Authentication

Requires one of the following:

- `BearerAuth`, http, header `Authorization`, format `JWT`
- `ApiKeyAuth`, apiKey, in header, header `X-API-Key`, format `API_KEY`

## Header parameters

- `x-workspace-id` (`post/api/oauth/connections.header.x-workspace-id`; string, required)

## Request body

_Required._

- `provider` (`post/api/oauth/connections.provider`; string, required)
  - example `"leadperfection"`
- `displayName` (`post/api/oauth/connections.displayName`; string, optional)
- `environment` (`post/api/oauth/connections.environment`; string, optional)
  - one of `"production"`, `"sandbox"`, `"integration"`
- `credentials` (`post/api/oauth/connections.credentials`; object, optional)
  - `username` (`post/api/oauth/connections.credentials.username`; string, optional)
  - `password` (`post/api/oauth/connections.credentials.password`; string, optional)
    - format `password`
  - `clientid` (`post/api/oauth/connections.credentials.clientid`; string, optional)
  - `appkey` (`post/api/oauth/connections.credentials.appkey`; string, optional)
    - format `password`
  - `apiBaseUrl` (`post/api/oauth/connections.credentials.apiBaseUrl`; string, optional)
    - example `"https://api2.leadperfection.com"`

## Example request

```json
{
  "provider": "leadperfection",
  "displayName": "string",
  "environment": "production",
  "credentials": {
    "username": "string",
    "password": "pa$$word",
    "clientid": "string",
    "appkey": "pa$$word",
    "apiBaseUrl": "https://api2.leadperfection.com"
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.channelautomation.com/api/oauth/connections \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-workspace-id: string' \
  --data '
{
  "provider": "leadperfection",
  "displayName": "string",
  "environment": "production",
  "credentials": {
    "username": "string",
    "password": "pa$$word",
    "clientid": "string",
    "appkey": "pa$$word",
    "apiBaseUrl": "https://api2.leadperfection.com"
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.channelautomation.com/api/oauth/connections';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-workspace-id': 'string',
    Authorization: 'Bearer <token>'
  },
  body: JSON.stringify({
    provider: 'leadperfection',
    displayName: 'string',
    environment: 'production',
    credentials: {
      username: 'string',
      password: 'pa$$word',
      clientid: 'string',
      appkey: 'pa$$word',
      apiBaseUrl: 'https://api2.leadperfection.com'
    }
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.channelautomation.com/api/oauth/connections"

payload = {
    "provider": "leadperfection",
    "displayName": "string",
    "environment": "production",
    "credentials": {
        "username": "string",
        "password": "pa$$word",
        "clientid": "string",
        "appkey": "pa$$word",
        "apiBaseUrl": "https://api2.leadperfection.com"
    }
}
headers = {
    "Content-Type": "application/json",
    "x-workspace-id": "string",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

Connection saved without returning sensitive fields.

### 400

Missing required fields.

### 500

Internal server error

#### Example

```json
{
  "error": "Internal server error",
  "details": "string",
  "success": false
}
```

- `error` (`post/api/oauth/connections.response.500.error`; string, optional)
  - example `"Internal server error"`
- `details` (`post/api/oauth/connections.response.500.details`; string, optional)
- `success` (`post/api/oauth/connections.response.500.success`; boolean, optional)
  - example `false`


Source: https://developer.channelautomations.com/api/post-api-oauth-connections/index.md
