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

# API Authentication

CCC APIs support two authentication methods:

1. **API Key**: Passed in the request headers for every call. The API key is also referred to Was the LoginId.
2. **OAuth 2.0** Available for systems that require token-based authorization flows.

## API Key Authentication

<Steps>
  <Step title="Create an API User">
    In the DNCScrub portal, navigate to **User Admin**. Create a new user that will be used for API access.

    * Give the user a distinct full name like "API User - Do Not Delete" so it won't be accidentally removed
    * The recommended username is `apiuser` (though any username works)
    * Set the user role to **Administrator**
  </Step>

  <Step title="Generate the API Key">
    After creating the user, click the **"Get API Key"** button. The API Key will be displayed in the "API Key" field and can be copied to your clipboard.
  </Step>

  <Step title="Store Your API Key">
    Save your API Key securely. You'll need it for all API calls.
  </Step>
</Steps>

## Using Your API Key

Include the API key in the HTTP header of every request:

| Header Key | Value        |
| ---------- | ------------ |
| `loginId`  | Your API Key |

### Example with cURL

```bash theme={null}
curl --location --request GET \
  'https://www.dncscrub.com/app/main/rpc/scrub?phoneList=7075276405&version=5&output=json' \
  --header 'loginId: YOUR_API_KEY_HERE'
```

### Example with JavaScript

```javascript theme={null}
fetch(
  "https://www.dncscrub.com/app/main/rpc/scrub?phoneList=7075276405&version=5&output=json",
  {
    method: "GET",
    headers: {
      loginId: "YOUR_API_KEY_HERE",
    },
  }
);
```

### Example with C\#

```csharp theme={null}
using (var client = new HttpClient())
{
    client.DefaultRequestHeaders.Add("loginId", "YOUR_API_KEY_HERE");
    var response = await client.GetStringAsync(
        "https://www.dncscrub.com/app/main/rpc/scrub?phoneList=7075276405&version=5&output=json"
    );
}
```

<Warning>
  Keep your API key secure and never expose it in client-side code or public
  repositories.
</Warning>

## OAuth 2.0 Authentication

For enhanced security, CCC APIs support OAuth 2.0 authentication in addition to API key authentication.

<Card title="OAuth Token API Playground" icon="key" href="/api-reference/other/oauth-token">
  Try the OAuth token endpoint directly in the API playground.
</Card>

### OAuth Flow

```mermaid theme={null}
sequenceDiagram
    autonumber
    participant Client as Client System
    participant OAuth as CCC OAuth Token Endpoint<br/>(/v1.5/oauth/token)
    participant API as CCC Service API Endpoint<br/>(Scrub API, IDNC API, etc.)

    Client->>OAuth: Request token (client_secret as credentials)
    OAuth-->>Client: Returns token (expires in 3600s / 1 hour)

    Client->>API: Call DNCScrub Service APIs<br/>with Token in Authorization header
    API-->>Client: DNCScrub API Response
```

<Steps>
  <Step title="Request Credentials">
    Contact support to receive your OAuth client credentials.
  </Step>

  <Step title="Get Access Token">
    Exchange credentials for an access token.
  </Step>

  <Step title="Make API Calls">Include the access token in API requests.</Step>

  <Step title="Refresh Token">
    Refresh the token before it expires (tokens expire after 1 hour).
  </Step>
</Steps>

### Token Request

```bash theme={null}
curl --location --request POST 'https://api.dncscrub.com/oauth/token' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'grant_type=client_credentials' \
  --data-urlencode 'client_id=YOUR_ACCOUNT_ID' \
  --data-urlencode 'client_secret=YOUR_CLIENT_SECRET'
```

#### Request Parameters

| Parameter       | Condition | Description                                    |
| --------------- | --------- | ---------------------------------------------- |
| `client_id`     | Required  | Your Account Id such as DEMO                   |
| `client_secret` | Required  | An API Key generated from DNCScrub.com portal. |
| `grant_type`    | Required  | Must be set to `client_credentials`            |

### Using the Access Token

```bash theme={null}
curl --location --request GET 'https://www.dncscrub.com/app/main/rpc/scrub?phoneList=7075276405&version=5' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'
```
