Source: https://docs.debitura.com/referral-partners/getting-started/environments

# Environments and test data

Referral partners receive access to the same core integration surface in both **test** and **production**. Operational behavior differs between environments as described below, and endpoints intended to create or manipulate test data are unavailable in production.

<a id="base-urls"></a>

## Base URLs

<a id="referral-partner-api"></a>

### Referral Partner API

| Environment | Base URL |
| --- | --- |
| Test | `https://testreferral-api.debitura.com` |
| Production | `https://referral-api.debitura.com` |

<a id="customer-api"></a>

### Customer API

| Environment | Base URL |
| --- | --- |
| Test | `https://testcustomer-api.debitura.com` |
| Production | `https://customer-api.debitura.com` |

<a id="white-label-onboarding-ui"></a>

### White-Label Onboarding UI

| Environment | Base URL |
| --- | --- |
| Test | `https://testreferral.debitura.com` |
| Production | `https://referral.debitura.com` |

<a id="client-application"></a>

### Client Application

| Environment | Base URL |
| --- | --- |
| Test | `https://testapp.debitura.com` |
| Production | `https://app.debitura.com` |

<a id="environment-differences"></a>

## Environment Differences

| Aspect | Test | Production |
| --- | --- | --- |
| Real collection activity | No | Yes |
| Emails sent | Suppressed\* | Yes |
| Data persistence | May be reset | Permanent |

_\*Email suppression:_ The test environment suppresses all emails to non-whitelisted domains by default. If you need to receive emails during testing, contact your Debitura partner contact to whitelist your domain.

<a id="test-data"></a>

## Test data

-   **`isTest: true`** on an invoice or case creates classified test data. It doesn't skip validation or business errors. Use it in test, and for a single dry run in production; see [Go live](https://docs.debitura.com/referral-partners/going-live-checklist.md).
-   **Completing onboarding in test.** Signing asks for a verification code sent by email, and test emails reach only whitelisted domains. Ask your partnership contact to arrange a test address that can receive the code. Complete the actual signing flow, then read the client's `onboardingDone` through the API.
-   **Public demo simulation.** The [test demo](https://testreferral.debitura.com/demo) uses `123456` only for an isolated demo session: both the partner and client must be marked as demo records. It demonstrates the screens without signing an actual agreement. A demo-flagged partner alone does not give ordinary `POST /clients` accounts a fixed verification code. See the [AI integration recipe](https://docs.debitura.com/referral-partners/getting-started/ai-integration-recipe.md).
-   **Use fictional companies and people** in test, never real client identities.

<a id="reset-test-clients"></a>

## Reset test clients

Delete test clients to re-run onboarding from scratch.

When testing the [client onboarding](https://docs.debitura.com/referral-partners/integration-guides/client-onboarding.md) flow multiple times with the same email, the matching algorithm returns 409 conflicts. The reset endpoints let you delete test clients so you can start fresh.

**Available on test environment only.** These endpoints return `403 Forbidden` in production.

<a id="check-if-deletable"></a>

### Check if Deletable

Before deleting, verify the client has no blocking data:

```http
GET https://testreferral-api.debitura.com/clients/{externalTenantId}/is-deletable
XApiKey: YOUR_API_KEY
```

**Response:**

```json
{
  "isDeletable": true,
  "blockers": []
}
```

If `isDeletable` is `false`, the `blockers` array contains plain strings explaining why (there is no wrapping object with a `reason` field). Only **active** state blocks deletion — already-closed cases do not:

| Blocker string | Solution |
| --- | --- |
| `Active case — must be closed before account deletion.` | Close the active case first |
| `You have pending lead quotes that must be resolved before deleting your account.` | Resolve leads with open quotes first |
| `Unpaid partner commission — must be reconciled before account deletion.` | Reconcile the outstanding partner commission first |

<a id="delete-the-client"></a>

### Delete the Client

Once verified deletable:

```http
DELETE https://testreferral-api.debitura.com/clients/{externalTenantId}
XApiKey: YOUR_API_KEY
```

Returns `204 No Content` on success.

**What gets deleted (cascade):**

-   All collection cases and invoices for the client (including invoice lines, payments, blobs)
-   All leads for the client
-   The Creditor account (soft-deleted)
-   The ReferralPartnerClientLink (archived)
-   Associated users (if they have no other creditor relations)

Nothing is retained — the reset removes the client and all of its child data so you can re-run onboarding from scratch.

<a id="after-reset"></a>

### After Reset

Call `POST /clients` with the same email:

-   The matching algorithm won't find the deleted client
-   A new client is created
-   `IsAttributedClient` is `true` (treated as new introduction)

<a id="constraints"></a>

### Constraints

-   **Your clients only** — You can only delete clients linked to your partner account
-   **Pending approvals unaffected** — If a client hasn't approved a link request (409 scenario), there's nothing to delete yet. The link request expires after the configured per-partner TTL (`ApprovalTtlDays`, default 7 days, clamped 1–30 days).

<a id="error-handling"></a>

### Error Handling

| Status | Cause | Solution |
| --- | --- | --- |
| `403 Forbidden` | Production environment | Only available on test |
| `404 Not Found` | No active link for this `externalTenantId` | Verify the tenant ID and that it still has an active client link |
| `422 Unprocessable` | Client has blockers | Check `is-deletable` first and resolve blockers |

See [Error Handling](https://docs.debitura.com/developer-concepts/error-handling.md) for the full error response format.

<a id="api-keys"></a>

## API Keys

API keys are provided during partner onboarding and are environment-specific. Contact [partnerships@debitura.com](mailto:partnerships@debitura.com) for setup.

See the [Referral Partner API Reference](https://docs.debitura.com/api/referral-partner.md) for client onboarding, token generation, and revenue reporting, and the [Customer API Reference](https://docs.debitura.com/api/customer.md) for case submission and management.
