# Setup Your Environment

Prepare your environment for development and testing.

Payment Network APIs require an OAuth access token for every authenticated request. After onboarding, Deluxe provides the credentials needed to obtain tokens and access Payment Network and DDN services.

Use this guide to verify authentication, connectivity, and access before you begin building and testing your integration.

Don't have credentials yet? Complete [onboarding](/products/deluxe-payment-network/build-with-deluxe/get-started) before continuing with implementation.

### Choose an Environment

Use the credentials and endpoints provided for your target environment.

| Environment | Token Endpoint | API Base URL |
|  --- | --- | --- |
| Sandbox (XUAT) | `https://developer.services.deluxe.com/oauth2/v2/token` | `https://stage.dcip.deluxe.com` |
| Production | `https://services.deluxe.com/oauth2/v2/token` | `https://dcip.deluxe.com` |


Use **Sandbox (XUAT)** during development and testing.
Use **Production** only after your integration has been approved for go-live.

### Generate an Access Token

Request an OAuth access token using the Client Credentials grant type.

#### Example Request

```bash
curl --location --request POST \
  'https://developer.services.deluxe.com/oauth2/v2/token' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --header 'Authorization: Basic <Base64(ClientID:ClientSecret)>' \
  --data-urlencode 'grant_type=client_credentials'
```

#### Example Response

```json
{
  "access_token": "eyJraWQiOiI4M3g5YWZXWUh2SVdLZlJ1b0Vid05QQ3p0Qy1CdTN4aWhrdk56Um1Va3ZnIiwiYWxnIjoiUlMy...",
  "tokenExpiry_time": "2025-10-16T10:59:29Z",
  "expires_in": 3300
}
```

A successful response confirms that your credentials are valid and that your application can authenticate successfully.

### Verify Connectivity

Use the access token to make a request to a Payment Network API.

#### Example Request

```bash
curl --location \
  'https://stage.dcip.deluxe.com/payables/dpxn/v1/payment-files/{file_guid}' \
  --header 'businessPartner: <your_businessPartner>' \
  --header 'Authorization: Bearer <access_token>'
```

A successful response confirms that:

- Your credentials are valid
- Authentication is configured correctly
- Required headers are present
- Connectivity to Payment Network services is working


### Access Directory Network Services

If your implementation uses the Deluxe Directory Network (DDN), include the `apiKey` header when calling Directory Network endpoints.

#### Example Request

```bash
curl --location \
  'https://stage.dcip.deluxe.com/payables/ddn/v1/lockbox' \
  --header 'apiKey: <your_apiKey>' \
  --header 'Authorization: Bearer <access_token>'
```

### Troubleshoot Common Issues

#### Access Token Was Not Provided

Verify that requests include a bearer token.

```http
Authorization: Bearer <access_token>
```

#### Unauthorized or Invalid Token

Verify that:

- The token has not expired
- The correct environment credentials are being used
- The `Authorization` header uses the `Bearer` scheme


#### Missing Service Credentials

Authentication may succeed while API requests still fail.

Confirm that the required service-specific headers are included:

| Service | Required Header |
|  --- | --- |
| Payment Network APIs | `businessPartner` |
| Directory Network APIs | `apiKey` |


### Verify Your Environment

Before continuing, confirm that you can:

Access the Sandbox (XUAT) environment.

Generate an access token.

Authenticate successfully.

Reach Payment Network services.

Access Directory Network services, if applicable.

Use the correct environment endpoints.

Call Payment Network APIs successfully.

Receive successful API responses.

Resolving connectivity and credential issues early helps avoid delays during implementation and testing.