Source: https://docs.debitura.com/api/referral-partner-api/oauth

# OAuth — Referral Partner API

Base URL: `https://referral-api.debitura.com`

Authentication: `XApiKey` API key; see [authentication](https://docs.debitura.com/developer-concepts/authentication.md).

Generated from [OpenAPI](https://docs.debitura.com/openapi/referral-partner-api.json). Examples are schema illustrations, not observed responses. Complete schemas, including recursive types, are in OpenAPI.

<a id="get-oauth-access-token"></a>

## Get OAuth access token

`POST /oauth/token`

Generates a short-lived JWT bearer token for accessing the Customer API on behalf of a specific client.

**How It Works:**
1. Authenticate with your referral partner API key (XApiKey header)
2. Provide the externalTenantId of the client you want to access
3. Receive a Bearer token valid for 30 minutes
4. Use the token in the Customer API: `Authorization: Bearer {access_token}`

**Requirements:**
- The externalTenantId must match an active ReferralPartnerClientLink for your partner account
- SDCA completion is not required to mint a token; contract requirements are enforced when submitting a case

**Token Details:**
- Type: Bearer (JWT)
- Lifetime: 30 minutes
- Scope: Customer API access for the specified client only

**Usage Example:**
```
POST /oauth/token
{ "externalTenantId": "your-client-id" }

Response:
{ "accessToken": "eyJ...", "tokenType": "Bearer", "expiresIn": 1800 }
```

### Request body (application/json)

- `externalTenantId` (string, required): The partner's external identifier for the client/tenant.
This must match an active ReferralPartnerClientLink.
  Max 255 characters.

```json
{
  "externalTenantId": "string"
}
```

### Response 200

Token generated successfully

- `accessToken` (string, nullable): The JWT bearer token to use in Authorization header.
Format: "Bearer {access_token}"
- `expiresIn` (integer): Token lifetime in seconds (typically 1800 for 30 minutes).
- `creditorId` (uuid): The Debitura creditor ID that this token grants access to.
- `externalTenantId` (string, nullable): The partner's external tenant ID for reference.
- `tokenType` (string, nullable): Token type - always "Bearer" for JWT tokens.

```json
{
  "accessToken": "string",
  "expiresIn": 3,
  "creditorId": "3f2b6c1e-8a4d-4b7f-9c2e-5d1a0b9e7f31",
  "externalTenantId": "string",
  "tokenType": "string"
}
```

### Response 400

Invalid request (missing or invalid externalTenantId)

- `error` (string, nullable): Short human-readable error label (legacy field — preserved for backward compatibility).
- `message` (string, nullable): Human-readable error description (legacy field — preserved for backward compatibility).
- `businessErrors` (array of objects, nullable): Canonical structured error array. Consumers should migrate to reading this field.
- `businessErrors[].type` (string, nullable): The type of business error (e.g., "MissingDebtCollectionContract", "MissingPowerOfAttorney", "NoPartnerAvailable").
- `businessErrors[].message` (string, nullable): A human-readable description of the error.
- `businessErrors[].solutionUrl` (string, nullable): A URL where the user can resolve this <i>specific</i> error (e.g., sign a contract).
            

Partners who want a <b>single URL</b> that walks the user through every pending
signing in one chain — instead of forwarding one URL per
`BusinessErrorApiDTO` — should use
SigningHandoff's `CombinedSigningUrl`.
The two are complementary: `SolutionUrl` is granular per-error;
`CombinedSigningUrl` is the chain-walking alternative for signing-related errors.

```json
{
  "error": null,
  "message": "Payment plan agreed with the debtor.",
  "businessErrors": [
    {
      "type": "string",
      "message": "Payment plan agreed with the debtor.",
      "solutionUrl": "https://app.debitura.com/…"
    }
  ]
}
```

### Response 404

Client not found (no active client link found for externalTenantId)

- `error` (string, nullable): Short human-readable error label (legacy field — preserved for backward compatibility).
- `message` (string, nullable): Human-readable error description (legacy field — preserved for backward compatibility).
- `businessErrors` (array of objects, nullable): Canonical structured error array. Consumers should migrate to reading this field.
- `businessErrors[].type` (string, nullable): The type of business error (e.g., "MissingDebtCollectionContract", "MissingPowerOfAttorney", "NoPartnerAvailable").
- `businessErrors[].message` (string, nullable): A human-readable description of the error.
- `businessErrors[].solutionUrl` (string, nullable): A URL where the user can resolve this <i>specific</i> error (e.g., sign a contract).
            

Partners who want a <b>single URL</b> that walks the user through every pending
signing in one chain — instead of forwarding one URL per
`BusinessErrorApiDTO` — should use
SigningHandoff's `CombinedSigningUrl`.
The two are complementary: `SolutionUrl` is granular per-error;
`CombinedSigningUrl` is the chain-walking alternative for signing-related errors.

```json
{
  "error": null,
  "message": "Payment plan agreed with the debtor.",
  "businessErrors": [
    {
      "type": "string",
      "message": "Payment plan agreed with the debtor.",
      "solutionUrl": "https://app.debitura.com/…"
    }
  ]
}
```

### Response 500

Internal server error

- `error` (string, nullable): Short human-readable error label (legacy field — preserved for backward compatibility).
- `message` (string, nullable): Human-readable error description (legacy field — preserved for backward compatibility).
- `businessErrors` (array of objects, nullable): Canonical structured error array. Consumers should migrate to reading this field.
- `businessErrors[].type` (string, nullable): The type of business error (e.g., "MissingDebtCollectionContract", "MissingPowerOfAttorney", "NoPartnerAvailable").
- `businessErrors[].message` (string, nullable): A human-readable description of the error.
- `businessErrors[].solutionUrl` (string, nullable): A URL where the user can resolve this <i>specific</i> error (e.g., sign a contract).
            

Partners who want a <b>single URL</b> that walks the user through every pending
signing in one chain — instead of forwarding one URL per
`BusinessErrorApiDTO` — should use
SigningHandoff's `CombinedSigningUrl`.
The two are complementary: `SolutionUrl` is granular per-error;
`CombinedSigningUrl` is the chain-walking alternative for signing-related errors.

```json
{
  "error": null,
  "message": "Payment plan agreed with the debtor.",
  "businessErrors": [
    {
      "type": "string",
      "message": "Payment plan agreed with the debtor.",
      "solutionUrl": "https://app.debitura.com/…"
    }
  ]
}
```
