> ## 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=8&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=8&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=8&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 86400s / 24 hours)

    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">
    Request a new token before it expires. Tokens are valid for 24 hours (`expires_in` is 86400 seconds). Always honor the `expires_in` value from the response rather than hard-coding a lifetime.
  </Step>
</Steps>

### Token Request

```bash theme={null}
curl --location --request POST 'https://dataapi.dncscrub.com/v1.5/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` |

The token endpoint is versioned like every other Data API endpoint; `v1.1` through `v1.5` all work. The unversioned path `/oauth/token` does not exist.

#### Token Response

```json theme={null}
{
  "token_type": "Bearer",
  "expires_in": 86400,
  "access_token": "YOUR_ACCESS_TOKEN"
}
```

### Using the Access Token

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.