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

# Partner quickstart

> Create a company with an inline admin, inspect readiness, and create its first delegated Case draft safely in a sandbox.

This quickstart uses a Partner sandbox credential. The Python examples use
`https://api-sandbox.paywise.de` directly; replace the inline
`PAYWISE_PARTNER_KEY` placeholder with a matching sandbox Partner key
(`pw_sbx_…`). Other language tabs read the matching environment variables.

The request tabs are complete examples for individual calls. The last section
provides one runnable Python program for environment proof, identifier capture,
and cross-API verification.

Use the documented trailing slash on `/partner/v2/` roots and resource
routes. Slashless requests return JSON `404` for every method, including
`GET`, `HEAD`, `OPTIONS`, and writes, with no redirect or `Location` header.
For example, request `/partner/v2/info/` directly. The same rule applies to
delegated `/v2/` requests; see
[canonical URLs](/api-docs/essentials/requests-and-responses#canonical-urls).

## 1. Prove the sandbox environment

Use the authenticated Partner information endpoint. Parse
`X-Paywise-Environment` case-insensitively and require its value to equal
`sandbox`; never infer the environment from the hostname.

<CodeGroup>
  ```python Python theme={null}
  import requests

  PAYWISE_API_URL = "https://api-sandbox.paywise.de"
  PAYWISE_PARTNER_KEY = "pw_sbx_your_partner_key"

  response = requests.get(
      f"{PAYWISE_API_URL}/partner/v2/info/",
      headers={"Authorization": f"Bearer {PAYWISE_PARTNER_KEY}"},
      timeout=(5, 30),
  )
  response.raise_for_status()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(`${process.env.PAYWISE_API_URL.replace(/\/$/, "")}/partner/v2/info/`, {
    method: "GET",
    headers: { Authorization: `Bearer ${process.env.PAYWISE_PARTNER_KEY}` },
    signal: AbortSignal.timeout(30000),
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  ```

  ```java Java theme={null}
  import java.io.IOException;
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.time.Duration;

  class PartnerQuickstartRequest {
    public static void main(String[] args) throws IOException, InterruptedException {
      HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
      HttpRequest request = HttpRequest.newBuilder()
          .uri(URI.create(System.getenv("PAYWISE_API_URL") + "/partner/v2/info/"))
          .timeout(Duration.ofSeconds(30))
          .header("Authorization", "Bearer " + System.getenv("PAYWISE_PARTNER_KEY"))
          .GET().build();
      HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
      if (response.statusCode() >= 400) throw new IOException(response.body());
    }
  }
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Threading;
  using System.Threading.Tasks;

  class PartnerQuickstartRequest
  {
      static async Task Main()
      {
          using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
          using var request = new HttpRequestMessage(HttpMethod.Get,
              $"{Environment.GetEnvironmentVariable("PAYWISE_API_URL")}/partner/v2/info/");
          request.Headers.Authorization = new("Bearer", Environment.GetEnvironmentVariable("PAYWISE_PARTNER_KEY"));
          using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30));
          using var response = await client.SendAsync(request, cancellation.Token);
          response.EnsureSuccessStatusCode();
      }
  }
  ```

  ```bash cURL theme={null}
  curl --fail-with-body --silent --show-error --connect-timeout 5 --max-time 30 \
    --request GET "$PAYWISE_API_URL/partner/v2/info/" \
    --header "Authorization: Bearer $PAYWISE_PARTNER_KEY"
  ```
</CodeGroup>

## 2. Create the company and inline admin atomically

Build the body once. A retry after an ambiguous outcome uses the same body and
`COMPANY_COMMAND_ID`; a new logical company uses a fresh key and run reference.

<CodeGroup>
  ```python Python theme={null}
  import requests

  PAYWISE_API_URL = "https://api-sandbox.paywise.de"
  PAYWISE_PARTNER_KEY = "pw_sbx_your_partner_key"
  COMPANY_COMMAND_ID = "your-company-command-id"
  RUN_ID = "80000000-0000-4000-8000-000000000001"

  run_id = RUN_ID
  company_payload = {
      "name": f"Partner Quickstart {run_id}",
      "onboarding_mode": "api_only",
      "legal_form": "gmbh",
      "address": {"street": "Musterstraße 1", "postal_code": "10115", "city": "Berlin", "country": "DE"},
      "phone": "+49301234567", "tax_treatment": "input_tax_deductible",
      "vat_number": "DE129273398", "default_claim_type": "H05",
      "data_sharing_basis": "self_authorized",
      "payout_bank_account": {"account_holder": f"Partner Quickstart {run_id}", "iban": "DE89370400440532013000", "bic": None},
      "notification_channels": [{"type": "email", "value": f"operations-{run_id}@example.test", "notifications": ["status_updates", "requests_to_client", "statements"]}],
      "legal_representatives": [{"type": "managing_director", "name": "Alex Example"}],
      "users": [{"email": f"admin-{run_id}@example.test", "first_name": "Alex", "last_name": "Example", "role": "admin"}],
  }
  response = requests.post(
      f"{PAYWISE_API_URL}/partner/v2/companies/",
      headers={
          "Authorization": f"Bearer {PAYWISE_PARTNER_KEY}",
          "Content-Type": "application/json",
          "Idempotency-Key": COMPANY_COMMAND_ID,
      },
      json=company_payload,
      timeout=(5, 30),
  )
  response.raise_for_status()
  ```

  ```javascript JavaScript theme={null}
  const runId = process.env.RUN_ID;
  const companyPayload = {
    name: `Partner Quickstart ${runId}`, onboarding_mode: "api_only", legal_form: "gmbh",
    address: { street: "Musterstraße 1", postal_code: "10115", city: "Berlin", country: "DE" },
    phone: "+49301234567", tax_treatment: "input_tax_deductible",
    vat_number: "DE129273398", default_claim_type: "H05", data_sharing_basis: "self_authorized",
    payout_bank_account: { account_holder: `Partner Quickstart ${runId}`, iban: "DE89370400440532013000", bic: null },
    notification_channels: [{ type: "email", value: `operations-${runId}@example.test`, notifications: ["status_updates", "requests_to_client", "statements"] }],
    legal_representatives: [{ type: "managing_director", name: "Alex Example" }],
    users: [{ email: `admin-${runId}@example.test`, first_name: "Alex", last_name: "Example", role: "admin" }],
  };
  const response = await fetch(`${process.env.PAYWISE_API_URL.replace(/\/$/, "")}/partner/v2/companies/`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.PAYWISE_PARTNER_KEY}`,
      "Content-Type": "application/json",
      "Idempotency-Key": process.env.COMPANY_COMMAND_ID,
    },
    body: JSON.stringify(companyPayload),
    signal: AbortSignal.timeout(30000),
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  ```

  ```java Java theme={null}
  import java.io.IOException;
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.time.Duration;

  class PartnerQuickstartRequest {
    static String jsonString(String value) {
      if (value == null) throw new IllegalArgumentException("Missing environment value");
      StringBuilder escaped = new StringBuilder("\"");
      for (int index = 0; index < value.length(); index++) {
        char character = value.charAt(index);
        switch (character) {
          case '\"': escaped.append("\\\""); break;
          case '\\': escaped.append("\\\\"); break;
          case '\b': escaped.append("\\b"); break;
          case '\f': escaped.append("\\f"); break;
          case '\n': escaped.append("\\n"); break;
          case '\r': escaped.append("\\r"); break;
          case '\t': escaped.append("\\t"); break;
          default:
            if (character < 0x20) escaped.append(String.format("\\u%04x", (int) character));
            else escaped.append(character);
        }
      }
      return escaped.append('\"').toString();
    }

    public static void main(String[] args) throws IOException, InterruptedException {
      String run = System.getenv("RUN_ID");
      String json = "{\"name\":" + jsonString("Partner Quickstart " + run) + ",\"onboarding_mode\":\"api_only\",\"legal_form\":\"gmbh\","
          + "\"address\":{\"street\":\"Musterstraße 1\",\"postal_code\":\"10115\",\"city\":\"Berlin\",\"country\":\"DE\"},"
          + "\"phone\":\"+49301234567\",\"tax_treatment\":\"input_tax_deductible\",\"vat_number\":\"DE129273398\","
          + "\"default_claim_type\":\"H05\",\"data_sharing_basis\":\"self_authorized\","
          + "\"payout_bank_account\":{\"account_holder\":" + jsonString("Partner Quickstart " + run) + ",\"iban\":\"DE89370400440532013000\",\"bic\":null},"
          + "\"notification_channels\":[{\"type\":\"email\",\"value\":" + jsonString("operations-" + run + "@example.test") + ","
          + "\"notifications\":[\"status_updates\",\"requests_to_client\",\"statements\"]}],"
          + "\"legal_representatives\":[{\"type\":\"managing_director\",\"name\":\"Alex Example\"}],"
          + "\"users\":[{\"email\":" + jsonString("admin-" + run + "@example.test") + ",\"first_name\":\"Alex\",\"last_name\":\"Example\",\"role\":\"admin\"}]}";
      HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
      HttpRequest request = HttpRequest.newBuilder()
          .uri(URI.create(System.getenv("PAYWISE_API_URL") + "/partner/v2/companies/"))
          .timeout(Duration.ofSeconds(30))
          .header("Authorization", "Bearer " + System.getenv("PAYWISE_PARTNER_KEY"))
          .header("Content-Type", "application/json")
          .header("Idempotency-Key", System.getenv("COMPANY_COMMAND_ID"))
          .POST(HttpRequest.BodyPublishers.ofString(json)).build();
      HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
      if (response.statusCode() >= 400) throw new IOException(response.body());
    }
  }
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Net.Http.Json;
  using System.Threading;
  using System.Threading.Tasks;

  class PartnerQuickstartRequest
  {
      static async Task Main()
      {
          var run = Environment.GetEnvironmentVariable("RUN_ID");
          var payload = new {
              name = $"Partner Quickstart {run}", onboarding_mode = "api_only", legal_form = "gmbh",
              address = new { street = "Musterstraße 1", postal_code = "10115", city = "Berlin", country = "DE" },
              phone = "+49301234567", tax_treatment = "input_tax_deductible",
              vat_number = "DE129273398", default_claim_type = "H05", data_sharing_basis = "self_authorized",
              payout_bank_account = new { account_holder = $"Partner Quickstart {run}", iban = "DE89370400440532013000", bic = (string?)null },
              notification_channels = new[] { new { type = "email", value = $"operations-{run}@example.test", notifications = new[] { "status_updates", "requests_to_client", "statements" } } },
              legal_representatives = new[] { new { type = "managing_director", name = "Alex Example" } },
              users = new[] { new { email = $"admin-{run}@example.test", first_name = "Alex", last_name = "Example", role = "admin" } }
          };
          using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
          using var request = new HttpRequestMessage(HttpMethod.Post,
              $"{Environment.GetEnvironmentVariable("PAYWISE_API_URL")}/partner/v2/companies/");
          request.Headers.Authorization = new("Bearer", Environment.GetEnvironmentVariable("PAYWISE_PARTNER_KEY"));
          request.Headers.Add("Idempotency-Key", Environment.GetEnvironmentVariable("COMPANY_COMMAND_ID"));
          request.Content = JsonContent.Create(payload);
          using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30));
          using var response = await client.SendAsync(request, cancellation.Token);
          response.EnsureSuccessStatusCode();
      }
  }
  ```

  ```bash cURL theme={null}
  curl --fail-with-body --silent --show-error --connect-timeout 5 --max-time 30 \
    --request POST "$PAYWISE_API_URL/partner/v2/companies/" \
    --header "Authorization: Bearer $PAYWISE_PARTNER_KEY" \
    --header "Content-Type: application/json" \
    --header "Idempotency-Key: $COMPANY_COMMAND_ID" \
    --data @- <<JSON
  {
    "name": "Partner Quickstart $RUN_ID",
    "onboarding_mode": "api_only",
    "legal_form": "gmbh",
    "address": {"street": "Musterstraße 1", "postal_code": "10115", "city": "Berlin", "country": "DE"},
    "phone": "+49301234567",
    "tax_treatment": "input_tax_deductible",
    "vat_number": "DE129273398",
    "default_claim_type": "H05",
    "data_sharing_basis": "self_authorized",
    "payout_bank_account": {
      "account_holder": "Partner Quickstart $RUN_ID",
      "iban": "DE89370400440532013000",
      "bic": null
    },
    "notification_channels": [{
      "type": "email",
      "value": "operations-$RUN_ID@example.test",
      "notifications": ["status_updates", "requests_to_client", "statements"]
    }],
    "legal_representatives": [{"type": "managing_director", "name": "Alex Example"}],
    "users": [{
      "email": "admin-$RUN_ID@example.test",
      "first_name": "Alex",
      "last_name": "Example",
      "role": "admin"
    }]
  }
  JSON
  ```
</CodeGroup>

The `201` response requires `id`, so capture that UUID directly. Do not list
companies and select the first result. Inspect `case_access` and every
`case_submission_readiness.issue` before attempting finalization; draft
creation itself does not require readiness.

## Create or reuse the delegated debtor

Use the Case Management API with the same `X-On-Behalf-Of-Company` header as the order.
The company UUID never belongs in either JSON body. Each tab parses the exact
returned debtor UUID and persists it as `DEBTOR_ID`.

<CodeGroup>
  ```python Python theme={null}
  import uuid
  import requests
  PAYWISE_API_URL = "https://api-sandbox.paywise.de"
  PAYWISE_PARTNER_KEY = "pw_sbx_your_partner_key"
  PAYWISE_COMPANY_ID = "20000000-0000-4000-8000-000000000001"
  DEBTOR_COMMAND_ID = "your-debtor-command-id"
  DEBTOR_REFERENCE = "quickstart-debtor-80000000-0000-4000-8000-000000000001"
  payload = {
      "your_reference": DEBTOR_REFERENCE, "acting_as": "consumer",
      "person": {"salutation": "mx", "first_name": "Taylor", "last_name": "Debtor"},
      "addresses": [{"street": "Example Street 12", "postal_code": "10115", "city": "Berlin", "country": "DE", "primary": True}],
  }
  response = requests.post(
      f"{PAYWISE_API_URL}/v2/debtors/",
      headers={"Authorization": f"Bearer {PAYWISE_PARTNER_KEY}", "X-On-Behalf-Of-Company": PAYWISE_COMPANY_ID, "Content-Type": "application/json", "Idempotency-Key": DEBTOR_COMMAND_ID},
      json=payload, timeout=(5, 30),
  )
  if response.status_code != 201:
      response.raise_for_status()
      raise RuntimeError(f"Expected 201, received {response.status_code}")
  debtor_id = str(uuid.UUID(response.json()["id"]))
  ```

  ```javascript JavaScript theme={null}
  const payload = {
    your_reference: process.env.DEBTOR_REFERENCE, acting_as: "consumer",
    person: { salutation: "mx", first_name: "Taylor", last_name: "Debtor" },
    addresses: [{ street: "Example Street 12", postal_code: "10115", city: "Berlin", country: "DE", primary: true }],
  };
  const response = await fetch(`${process.env.PAYWISE_API_URL.replace(/\/$/, "")}/v2/debtors/`, {
    method: "POST",
    headers: { Authorization: `Bearer ${process.env.PAYWISE_PARTNER_KEY}`, "X-On-Behalf-Of-Company": process.env.PAYWISE_COMPANY_ID, "Content-Type": "application/json", "Idempotency-Key": process.env.DEBTOR_COMMAND_ID },
    body: JSON.stringify(payload), signal: AbortSignal.timeout(30000),
  });
  if (response.status !== 201) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  const debtorId = (await response.json()).id;
  if (!/^[0-9a-f-]{36}$/i.test(debtorId)) throw new Error("Invalid debtor UUID");
  ```

  ```java Java theme={null}
  import java.io.IOException;
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.time.Duration;
  class CreateDelegatedDebtorRequest {
    public static void main(String[] args) throws IOException, InterruptedException {
      String json = "{\"your_reference\":\"quickstart-debtor-80000000-0000-4000-8000-000000000001\",\"acting_as\":\"consumer\",\"person\":{\"salutation\":\"mx\",\"first_name\":\"Taylor\",\"last_name\":\"Debtor\"},\"addresses\":[{\"street\":\"Example Street 12\",\"postal_code\":\"10115\",\"city\":\"Berlin\",\"country\":\"DE\",\"primary\":true}]}";
      HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
      HttpRequest request = HttpRequest.newBuilder().uri(URI.create(System.getenv("PAYWISE_API_URL") + "/v2/debtors/"))
          .timeout(Duration.ofSeconds(30)).header("Authorization", "Bearer " + System.getenv("PAYWISE_PARTNER_KEY"))
          .header("X-On-Behalf-Of-Company", System.getenv("PAYWISE_COMPANY_ID")).header("Content-Type", "application/json")
          .header("Idempotency-Key", System.getenv("DEBTOR_COMMAND_ID")).POST(HttpRequest.BodyPublishers.ofString(json)).build();
      HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
      if (response.statusCode() != 201) throw new IOException(response.body());
      String debtorId = response.body().replaceFirst("(?s).*\\\"id\\\"\\s*:\\s*\\\"([0-9a-fA-F-]{36})\\\".*", "$1");
      if (debtorId.equals(response.body())) throw new IOException("Missing debtor UUID");
    }
  }
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Net.Http.Json;
  using System.Text.Json;
  using System.Threading;
  using System.Threading.Tasks;
  class CreateDelegatedDebtorRequest {
      static async Task Main() {
          using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
          var payload = new {
              your_reference = "quickstart-debtor-80000000-0000-4000-8000-000000000001", acting_as = "consumer",
              person = new { salutation = "mx", first_name = "Taylor", last_name = "Debtor" },
              addresses = new[] { new { street = "Example Street 12", postal_code = "10115", city = "Berlin", country = "DE", primary = true } }
          };
          using var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("PAYWISE_API_URL")}/v2/debtors/");
          request.Headers.Authorization = new("Bearer", Environment.GetEnvironmentVariable("PAYWISE_PARTNER_KEY"));
          request.Headers.Add("X-On-Behalf-Of-Company", Environment.GetEnvironmentVariable("PAYWISE_COMPANY_ID"));
          request.Headers.Add("Idempotency-Key", Environment.GetEnvironmentVariable("DEBTOR_COMMAND_ID"));
          request.Content = JsonContent.Create(payload);
          using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30));
          using var response = await client.SendAsync(request, cancellation.Token);
          if ((int)response.StatusCode != 201) throw new HttpRequestException(await response.Content.ReadAsStringAsync());
          using var debtor = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
          var debtorId = debtor.RootElement.GetProperty("id").GetGuid();
      }
  }
  ```

  ```bash cURL theme={null}
  status="$(curl --fail-with-body --silent --show-error --connect-timeout 5 --max-time 30 \
    --request POST "$PAYWISE_API_URL/v2/debtors/" \
    --header "Authorization: Bearer $PAYWISE_PARTNER_KEY" \
    --header "X-On-Behalf-Of-Company: $PAYWISE_COMPANY_ID" \
    --header "Content-Type: application/json" \
    --header "Idempotency-Key: $DEBTOR_COMMAND_ID" \
    --output debtor-created.json --write-out '%{http_code}' \
    --data '{"your_reference":"quickstart-debtor-80000000-0000-4000-8000-000000000001","acting_as":"consumer","person":{"salutation":"mx","first_name":"Taylor","last_name":"Debtor"},"addresses":[{"street":"Example Street 12","postal_code":"10115","city":"Berlin","country":"DE","primary":true}]}')"
  [ "$status" -eq 201 ] || exit 1
  DEBTOR_ID="$(jq -er '.id' debtor-created.json)" || exit 1
  ```
</CodeGroup>

## 3. Create a delegated Case draft

The company UUID belongs only in `X-On-Behalf-Of-Company`. Never add it to the
JSON body. From the complete `201` order response, match exactly one claim whose
`your_reference` equals `CLAIM_REFERENCE`; persist that claim's `id` rather
than taking a positional element.

<CodeGroup>
  ```python Python theme={null}
  import requests

  PAYWISE_API_URL = "https://api-sandbox.paywise.de"
  PAYWISE_PARTNER_KEY = "pw_sbx_your_partner_key"
  CLAIM_REFERENCE = "quickstart-claim-80000000-0000-4000-8000-000000000001"
  DEBTOR_REFERENCE = "quickstart-debtor-80000000-0000-4000-8000-000000000001"
  DEBTOR_ID = debtor_id  # Parsed from the immediately preceding create response.
  ORDER_COMMAND_ID = "your-order-command-id"
  PAYWISE_COMPANY_ID = "20000000-0000-4000-8000-000000000001"

  order_payload = {
      "debtor_id": DEBTOR_ID,
      "additional_debtor_ids": [], "starting_approach": "extrajudicial",
      "creditor_obligation_fulfilled": True,
      "claims": [{
          "type": "receivable",
          "your_reference": CLAIM_REFERENCE, "document_reference": "INV-2026-0042",
          "subject_matter": "Consulting services for June 2026",
          "principal_amount": {"value": "125.50", "currency": "EUR"},
          "document_date": "2026-06-30", "due_date": "2026-07-14", "is_disputed": False,
          "items": [], "additional_charges": [], "reminders": [], "documents": [],
          "legal_basis": {"claim_type_code": "H05", "contract_date": "2026-06-01", "description": "Consulting agreement"},
      }],
  }
  response = requests.post(
      f"{PAYWISE_API_URL}/v2/orders/",
      headers={
          "Authorization": f"Bearer {PAYWISE_PARTNER_KEY}",
          "X-On-Behalf-Of-Company": PAYWISE_COMPANY_ID,
          "Content-Type": "application/json",
          "Idempotency-Key": ORDER_COMMAND_ID,
      },
      json=order_payload,
      timeout=(5, 30),
  )
  if response.status_code != 201:
      response.raise_for_status()
      raise RuntimeError(f"Expected 201, received {response.status_code}")
  order = response.json()
  order_id = order["id"]
  matching_claims = [
      claim for claim in order.get("claims", [])
      if claim.get("your_reference") == CLAIM_REFERENCE
  ]
  if len(matching_claims) != 1:
      raise RuntimeError("Expected exactly one matching claim")
  claim_id = matching_claims[0]["id"]
  ```

  ```javascript JavaScript theme={null}
  const orderPayload = {
    debtor_id: process.env.DEBTOR_ID,
    additional_debtor_ids: [], starting_approach: "extrajudicial", creditor_obligation_fulfilled: true,
    claims: [{
      type: "receivable",
      your_reference: process.env.CLAIM_REFERENCE, document_reference: "INV-2026-0042",
      subject_matter: "Consulting services for June 2026", principal_amount: { value: "125.50", currency: "EUR" },
      document_date: "2026-06-30", due_date: "2026-07-14", is_disputed: false,
      items: [], additional_charges: [], reminders: [], documents: [],
      legal_basis: { claim_type_code: "H05", contract_date: "2026-06-01", description: "Consulting agreement" },
    }],
  };
  const response = await fetch(`${process.env.PAYWISE_API_URL.replace(/\/$/, "")}/v2/orders/`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.PAYWISE_PARTNER_KEY}`,
      "X-On-Behalf-Of-Company": process.env.PAYWISE_COMPANY_ID,
      "Content-Type": "application/json",
      "Idempotency-Key": process.env.ORDER_COMMAND_ID,
    },
    body: JSON.stringify(orderPayload),
    signal: AbortSignal.timeout(30000),
  });
  if (response.status !== 201) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  const order = await response.json();
  const orderId = order.id;
  const matchingClaims = order.claims.filter(
    (claim) => claim.your_reference === process.env.CLAIM_REFERENCE,
  );
  if (matchingClaims.length !== 1) throw new Error("Expected exactly one matching claim");
  const claimId = matchingClaims[0].id;
  ```

  ```java Java theme={null}
  import java.io.IOException;
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.time.Duration;

  class PartnerQuickstartRequest {
    static String jsonString(String value) {
      if (value == null) throw new IllegalArgumentException("Missing environment value");
      StringBuilder escaped = new StringBuilder("\"");
      for (int index = 0; index < value.length(); index++) {
        char character = value.charAt(index);
        switch (character) {
          case '\"': escaped.append("\\\""); break;
          case '\\': escaped.append("\\\\"); break;
          case '\b': escaped.append("\\b"); break;
          case '\f': escaped.append("\\f"); break;
          case '\n': escaped.append("\\n"); break;
          case '\r': escaped.append("\\r"); break;
          case '\t': escaped.append("\\t"); break;
          default:
            if (character < 0x20) escaped.append(String.format("\\u%04x", (int) character));
            else escaped.append(character);
        }
      }
      return escaped.append('\"').toString();
    }

    static int closingDelimiter(String json, int opening, char open, char close) {
      int depth = 0;
      boolean inString = false;
      boolean escaped = false;
      for (int index = opening; index < json.length(); index++) {
        char character = json.charAt(index);
        if (inString) {
          if (escaped) escaped = false;
          else if (character == '\\') escaped = true;
          else if (character == '\"') inString = false;
        } else if (character == '\"') inString = true;
        else if (character == open) depth++;
        else if (character == close && --depth == 0) return index;
      }
      throw new IllegalArgumentException("Malformed JSON response");
    }
    static int closingQuote(String json, int opening) {
      boolean escaped = false;
      for (int index = opening + 1; index < json.length(); index++) {
        char character = json.charAt(index);
        if (escaped) escaped = false;
        else if (character == '\\') escaped = true;
        else if (character == '\"') return index;
      }
      throw new IllegalArgumentException("Malformed JSON string");
    }
    static int hexDigit(char character) {
      if (character >= '0' && character <= '9') return character - '0';
      if (character >= 'a' && character <= 'f') return character - 'a' + 10;
      if (character >= 'A' && character <= 'F') return character - 'A' + 10;
      throw new IllegalArgumentException("Malformed Unicode escape");
    }
    static int unicodeEscape(String json, int firstDigit, int closing) {
      if (firstDigit + 4 > closing) throw new IllegalArgumentException("Malformed Unicode escape");
      int value = 0;
      for (int index = firstDigit; index < firstDigit + 4; index++)
        value = value * 16 + hexDigit(json.charAt(index));
      return value;
    }
    static String decodeJsonString(String json, int opening, int closing) {
      StringBuilder decoded = new StringBuilder();
      for (int index = opening + 1; index < closing; index++) {
        char character = json.charAt(index);
        if (character == '\\') {
          if (++index >= closing) throw new IllegalArgumentException("Malformed JSON escape");
          char escape = json.charAt(index);
          switch (escape) {
            case '\"': decoded.append('\"'); break;
            case '\\': decoded.append('\\'); break;
            case '/': decoded.append('/'); break;
            case 'b': decoded.append('\b'); break;
            case 'f': decoded.append('\f'); break;
            case 'n': decoded.append('\n'); break;
            case 'r': decoded.append('\r'); break;
            case 't': decoded.append('\t'); break;
            case 'u':
              char unit = (char) unicodeEscape(json, index + 1, closing);
              index += 4;
              if (Character.isHighSurrogate(unit)) {
                if (index + 6 >= closing || json.charAt(index + 1) != '\\' || json.charAt(index + 2) != 'u')
                  throw new IllegalArgumentException("Missing low surrogate");
                char low = (char) unicodeEscape(json, index + 3, closing);
                if (!Character.isLowSurrogate(low)) throw new IllegalArgumentException("Invalid low surrogate");
                decoded.appendCodePoint(Character.toCodePoint(unit, low));
                index += 6;
              } else if (Character.isLowSurrogate(unit)) throw new IllegalArgumentException("Unexpected low surrogate");
              else decoded.append(unit);
              break;
            default: throw new IllegalArgumentException("Unsupported JSON escape");
          }
        } else {
          if (character < 0x20) throw new IllegalArgumentException("Unescaped control character");
          if (Character.isHighSurrogate(character)) {
            if (index + 1 >= closing || !Character.isLowSurrogate(json.charAt(index + 1)))
              throw new IllegalArgumentException("Missing raw low surrogate");
            decoded.append(character).append(json.charAt(++index));
          } else if (Character.isLowSurrogate(character)) throw new IllegalArgumentException("Unexpected raw low surrogate");
          else decoded.append(character);
        }
      }
      return decoded.toString();
    }
    static String directStringField(String object, String wanted) {
      int opening = 0;
      while (opening < object.length() && Character.isWhitespace(object.charAt(opening))) opening++;
      if (opening >= object.length() || object.charAt(opening) != '{')
        throw new IllegalArgumentException("Expected JSON object");
      int closing = closingDelimiter(object, opening, '{', '}');
      for (int cursor = opening + 1; cursor < closing;) {
        while (cursor < closing && (Character.isWhitespace(object.charAt(cursor)) || object.charAt(cursor) == ',')) cursor++;
        if (cursor >= closing) break;
        if (object.charAt(cursor) != '\"') throw new IllegalArgumentException("Malformed JSON field");
        int keyClosing = closingQuote(object, cursor);
        String key = decodeJsonString(object, cursor, keyClosing);
        cursor = keyClosing + 1;
        while (cursor < closing && Character.isWhitespace(object.charAt(cursor))) cursor++;
        if (cursor >= closing || object.charAt(cursor++) != ':') throw new IllegalArgumentException("Malformed JSON field");
        while (cursor < closing && Character.isWhitespace(object.charAt(cursor))) cursor++;
        if (cursor >= closing) throw new IllegalArgumentException("Missing JSON value");
        char valueStart = object.charAt(cursor);
        if (valueStart == '\"') {
          int valueClosing = closingQuote(object, cursor);
          if (key.equals(wanted)) return decodeJsonString(object, cursor, valueClosing);
          cursor = valueClosing + 1;
        } else if (valueStart == '{' || valueStart == '[') {
          char valueClose = valueStart == '{' ? '}' : ']';
          if (key.equals(wanted)) throw new IllegalArgumentException("Expected string field " + wanted);
          cursor = closingDelimiter(object, cursor, valueStart, valueClose) + 1;
        } else {
          if (key.equals(wanted)) throw new IllegalArgumentException("Expected string field " + wanted);
          while (cursor < closing && object.charAt(cursor) != ',') cursor++;
        }
      }
      return null;
    }
    static String topLevelId(String object) {
      String id = object.replaceFirst(
          "(?s)^\\s*\\{(?:(?!\\{).)*?\\\"id\\\"\\s*:\\s*\\\"([^\\\"]+)\\\".*$", "$1");
      if (id.equals(object)) throw new IllegalArgumentException("Missing top-level id");
      return id;
    }
    static String[] responseIds(String body, String reference) {
      if (reference == null) throw new IllegalArgumentException("Missing business reference");
      String orderId = topLevelId(body);
      java.util.regex.Matcher claims = java.util.regex.Pattern
          .compile("\\\"claims\\\"\\s*:\\s*\\[").matcher(body);
      if (!claims.find()) throw new IllegalArgumentException("Missing claims collection");
      int opening = body.indexOf('[', claims.start());
      int closing = closingDelimiter(body, opening, '[', ']');
      int matches = 0;
      String claimId = null;
      for (int cursor = opening + 1; cursor < closing;) {
        while (cursor < closing && (Character.isWhitespace(body.charAt(cursor)) || body.charAt(cursor) == ',')) cursor++;
        if (cursor >= closing) break;
        if (body.charAt(cursor) != '{') throw new IllegalArgumentException("Malformed claim object");
        int claimClosing = closingDelimiter(body, cursor, '{', '}');
        String claim = body.substring(cursor, claimClosing + 1);
        if (reference.equals(directStringField(claim, "your_reference"))) {
          matches++;
          claimId = directStringField(claim, "id");
          if (claimId == null) throw new IllegalArgumentException("Missing direct claim id");
        }
        cursor = claimClosing + 1;
      }
      if (matches != 1) throw new IllegalArgumentException("Expected exactly one matching claim");
      return new String[] {orderId, claimId};
    }

    public static void main(String[] args) throws IOException, InterruptedException {
      String json = "{\"debtor_id\":" + jsonString(System.getenv("DEBTOR_ID"))
          + ",\"additional_debtor_ids\":[],\"starting_approach\":\"extrajudicial\",\"creditor_obligation_fulfilled\":true,\"claims\":[{\"type\":\"receivable\","
          + "\"your_reference\":" + jsonString(System.getenv("CLAIM_REFERENCE")) + ",\"document_reference\":\"INV-2026-0042\","
          + "\"subject_matter\":\"Consulting services for June 2026\",\"principal_amount\":{\"value\":\"125.50\",\"currency\":\"EUR\"},"
          + "\"document_date\":\"2026-06-30\",\"due_date\":\"2026-07-14\",\"is_disputed\":false,\"items\":[],"
          + "\"additional_charges\":[],\"reminders\":[],\"documents\":[],\"legal_basis\":{\"claim_type_code\":\"H05\","
          + "\"contract_date\":\"2026-06-01\",\"description\":\"Consulting agreement\"}}]}";
      HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
      HttpRequest request = HttpRequest.newBuilder()
          .uri(URI.create(System.getenv("PAYWISE_API_URL") + "/v2/orders/"))
          .timeout(Duration.ofSeconds(30))
          .header("Authorization", "Bearer " + System.getenv("PAYWISE_PARTNER_KEY"))
          .header("X-On-Behalf-Of-Company", System.getenv("PAYWISE_COMPANY_ID"))
          .header("Content-Type", "application/json")
          .header("Idempotency-Key", System.getenv("ORDER_COMMAND_ID"))
          .POST(HttpRequest.BodyPublishers.ofString(json)).build();
      HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
      if (response.statusCode() != 201) throw new IOException(response.body());
      String[] ids = responseIds(response.body(), System.getenv("CLAIM_REFERENCE"));
      String orderId = ids[0];
      String claimId = ids[1];
    }
  }
  ```

  ```csharp C# theme={null}
  using System;
  using System.Linq;
  using System.Net.Http;
  using System.Net.Http.Json;
  using System.Text.Json;
  using System.Threading;
  using System.Threading.Tasks;

  class PartnerQuickstartRequest
  {
      static async Task Main()
      {
          var payload = new {
              debtor_id = Environment.GetEnvironmentVariable("DEBTOR_ID"),
              additional_debtor_ids = Array.Empty<string>(), starting_approach = "extrajudicial", creditor_obligation_fulfilled = true,
              claims = new[] { new {
                  type = "receivable",
                  your_reference = Environment.GetEnvironmentVariable("CLAIM_REFERENCE"), document_reference = "INV-2026-0042",
                  subject_matter = "Consulting services for June 2026", principal_amount = new { value = "125.50", currency = "EUR" },
                  document_date = "2026-06-30", due_date = "2026-07-14", is_disputed = false,
                  items = Array.Empty<object>(), additional_charges = Array.Empty<object>(), reminders = Array.Empty<object>(), documents = Array.Empty<object>(),
                  legal_basis = new { claim_type_code = "H05", contract_date = "2026-06-01", description = "Consulting agreement" }
              } }
          };
          using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
          using var request = new HttpRequestMessage(HttpMethod.Post,
              $"{Environment.GetEnvironmentVariable("PAYWISE_API_URL")}/v2/orders/");
          request.Headers.Authorization = new("Bearer", Environment.GetEnvironmentVariable("PAYWISE_PARTNER_KEY"));
          request.Headers.Add("X-On-Behalf-Of-Company", Environment.GetEnvironmentVariable("PAYWISE_COMPANY_ID"));
          request.Headers.Add("Idempotency-Key", Environment.GetEnvironmentVariable("ORDER_COMMAND_ID"));
          request.Content = JsonContent.Create(payload);
          using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30));
          using var response = await client.SendAsync(request, cancellation.Token);
          if ((int)response.StatusCode != 201) throw new HttpRequestException(await response.Content.ReadAsStringAsync());
          using var order = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
          var orderId = order.RootElement.GetProperty("id").GetString();
          var claimReference = Environment.GetEnvironmentVariable("CLAIM_REFERENCE");
          var matches = order.RootElement.GetProperty("claims").EnumerateArray()
              .Where(claim => claim.GetProperty("your_reference").GetString() == claimReference)
              .ToArray();
          if (matches.Length != 1) throw new InvalidOperationException("Expected exactly one matching claim");
          var claimId = matches[0].GetProperty("id").GetString();
      }
  }
  ```

  ```bash cURL theme={null}
  http_status="$(curl --fail-with-body --silent --show-error --connect-timeout 5 --max-time 30 \
    --request POST "$PAYWISE_API_URL/v2/orders/" \
    --header "Authorization: Bearer $PAYWISE_PARTNER_KEY" \
    --header "X-On-Behalf-Of-Company: $PAYWISE_COMPANY_ID" \
    --header "Content-Type: application/json" \
    --header "Idempotency-Key: $ORDER_COMMAND_ID" \
    --output order-created.json --write-out '%{http_code}' \
    --data @- <<JSON
  {
    "debtor_id": "$DEBTOR_ID",
    "additional_debtor_ids": [],
    "starting_approach": "extrajudicial",
    "creditor_obligation_fulfilled": true,
    "claims": [{
      "type": "receivable",
      "your_reference": "$CLAIM_REFERENCE",
      "document_reference": "INV-2026-0042",
      "subject_matter": "Consulting services for June 2026",
      "principal_amount": {"value": "125.50", "currency": "EUR"},
      "document_date": "2026-06-30",
      "due_date": "2026-07-14",
      "is_disputed": false,
      "items": [],
      "additional_charges": [],
      "reminders": [],
      "documents": [],
      "legal_basis": {
        "claim_type_code": "H05",
        "contract_date": "2026-06-01",
        "description": "Consulting agreement"
      }
    }]
  }
  JSON
  )"
  [ "$http_status" -eq 201 ] || exit 1
  ORDER_ID="$(jq -er '.id' order-created.json)" || exit 1
  CLAIM_ID="$(jq -er --arg ref "$CLAIM_REFERENCE" \
    '[.claims[] | select(.your_reference == $ref)] | if length == 1 then .[0].id else error("expected exactly one matching claim") end' \
    order-created.json)" || exit 1
  ```
</CodeGroup>

<Note>
  `X-On-Behalf-Of-Company` is the only delegated tenant selector. There is no
  `X-User-Id`, public `access_mode`, per-company Partner secret, or public API
  key minting endpoint.
</Note>

## 4. Verify through exact resource URLs

Read the company through the Partner API and the draft through the delegated
Case Management API. Check each returned `id`; never use a response request ID as a
resource identifier.

<CodeGroup>
  ```python Python theme={null}
  import requests

  PAYWISE_API_URL = "https://api-sandbox.paywise.de"
  PAYWISE_PARTNER_KEY = "pw_sbx_your_partner_key"
  PAYWISE_COMPANY_ID = "20000000-0000-4000-8000-000000000001"

  response = requests.get(
      f"{PAYWISE_API_URL}/partner/v2/companies/{PAYWISE_COMPANY_ID}/",
      headers={"Authorization": f"Bearer {PAYWISE_PARTNER_KEY}"},
      timeout=(5, 30),
  )
  response.raise_for_status()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(`${process.env.PAYWISE_API_URL.replace(/\/$/, "")}/partner/v2/companies/${process.env.PAYWISE_COMPANY_ID}/`, {
    method: "GET",
    headers: { Authorization: `Bearer ${process.env.PAYWISE_PARTNER_KEY}` },
    signal: AbortSignal.timeout(30000),
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  ```

  ```java Java theme={null}
  import java.io.IOException;
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.time.Duration;

  class PartnerQuickstartRequest {
    public static void main(String[] args) throws IOException, InterruptedException {
      HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
      HttpRequest request = HttpRequest.newBuilder()
          .uri(URI.create(System.getenv("PAYWISE_API_URL") + "/partner/v2/companies/" + System.getenv("PAYWISE_COMPANY_ID") + "/"))
          .timeout(Duration.ofSeconds(30))
          .header("Authorization", "Bearer " + System.getenv("PAYWISE_PARTNER_KEY"))
          .GET().build();
      HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
      if (response.statusCode() >= 400) throw new IOException(response.body());
    }
  }
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Threading;
  using System.Threading.Tasks;

  class PartnerQuickstartRequest
  {
      static async Task Main()
      {
          using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
          using var request = new HttpRequestMessage(HttpMethod.Get,
              $"{Environment.GetEnvironmentVariable("PAYWISE_API_URL")}/partner/v2/companies/{Environment.GetEnvironmentVariable("PAYWISE_COMPANY_ID")}/");
          request.Headers.Authorization = new("Bearer", Environment.GetEnvironmentVariable("PAYWISE_PARTNER_KEY"));
          using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30));
          using var response = await client.SendAsync(request, cancellation.Token);
          response.EnsureSuccessStatusCode();
      }
  }
  ```

  ```bash cURL theme={null}
  curl --fail-with-body --silent --show-error --connect-timeout 5 --max-time 30 \
    --request GET "$PAYWISE_API_URL/partner/v2/companies/$PAYWISE_COMPANY_ID/" \
    --header "Authorization: Bearer $PAYWISE_PARTNER_KEY"
  ```
</CodeGroup>

<CodeGroup>
  ```python Python theme={null}
  import requests

  PAYWISE_API_URL = "https://api-sandbox.paywise.de"
  PAYWISE_PARTNER_KEY = "pw_sbx_your_partner_key"
  ORDER_ID = "30000000-0000-4000-8000-000000000001"
  PAYWISE_COMPANY_ID = "20000000-0000-4000-8000-000000000001"

  response = requests.get(
      f"{PAYWISE_API_URL}/v2/orders/{ORDER_ID}/",
      headers={
          "Authorization": f"Bearer {PAYWISE_PARTNER_KEY}",
          "X-On-Behalf-Of-Company": PAYWISE_COMPANY_ID,
      },
      timeout=(5, 30),
  )
  response.raise_for_status()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(`${process.env.PAYWISE_API_URL.replace(/\/$/, "")}/v2/orders/${process.env.ORDER_ID}/`, {
    method: "GET",
    headers: {
      Authorization: `Bearer ${process.env.PAYWISE_PARTNER_KEY}`,
      "X-On-Behalf-Of-Company": process.env.PAYWISE_COMPANY_ID,
    },
    signal: AbortSignal.timeout(30000),
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  ```

  ```java Java theme={null}
  import java.io.IOException;
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.time.Duration;

  class PartnerQuickstartRequest {
    public static void main(String[] args) throws IOException, InterruptedException {
      HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(5)).build();
      HttpRequest request = HttpRequest.newBuilder()
          .uri(URI.create(System.getenv("PAYWISE_API_URL") + "/v2/orders/" + System.getenv("ORDER_ID") + "/"))
          .timeout(Duration.ofSeconds(30))
          .header("Authorization", "Bearer " + System.getenv("PAYWISE_PARTNER_KEY"))
          .header("X-On-Behalf-Of-Company", System.getenv("PAYWISE_COMPANY_ID"))
          .GET().build();
      HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
      if (response.statusCode() >= 400) throw new IOException(response.body());
    }
  }
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Threading;
  using System.Threading.Tasks;

  class PartnerQuickstartRequest
  {
      static async Task Main()
      {
          using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
          using var request = new HttpRequestMessage(HttpMethod.Get,
              $"{Environment.GetEnvironmentVariable("PAYWISE_API_URL")}/v2/orders/{Environment.GetEnvironmentVariable("ORDER_ID")}/");
          request.Headers.Authorization = new("Bearer", Environment.GetEnvironmentVariable("PAYWISE_PARTNER_KEY"));
          request.Headers.Add("X-On-Behalf-Of-Company", Environment.GetEnvironmentVariable("PAYWISE_COMPANY_ID"));
          using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30));
          using var response = await client.SendAsync(request, cancellation.Token);
          response.EnsureSuccessStatusCode();
      }
  }
  ```

  ```bash cURL theme={null}
  curl --fail-with-body --silent --show-error --connect-timeout 5 --max-time 30 \
    --request GET "$PAYWISE_API_URL/v2/orders/$ORDER_ID/" \
    --header "Authorization: Bearer $PAYWISE_PARTNER_KEY" \
    --header "X-On-Behalf-Of-Company: $PAYWISE_COMPANY_ID"
  ```
</CodeGroup>

## 5. Runnable end-to-end workflow

Install `requests`, replace the inline `PAYWISE_PARTNER_KEY` placeholder, and
run:

```python Python workflow theme={null}
import uuid

import requests

PAYWISE_API_URL = "https://api-sandbox.paywise.de"
PAYWISE_PARTNER_KEY = "pw_sbx_your_partner_key"

TIMEOUT = (5, 30)


def checked(response, expected):
    response.raise_for_status()
    if response.status_code not in expected:
        raise RuntimeError(f"Unexpected HTTP status {response.status_code}")
    return response


def environment_header(response):
    return next(
        (value for name, value in response.headers.items()
         if name.lower() == "x-paywise-environment"),
        None,
    )


def main():
    base_url = PAYWISE_API_URL
    if not base_url.startswith("https://"):
        raise ValueError("PAYWISE_API_URL must be an HTTPS sandbox URL")

    session = requests.Session()
    session.headers.update({
        "Authorization": f"Bearer {PAYWISE_PARTNER_KEY}",
        "Accept": "application/json",
    })
    probe = checked(
        session.get(f"{base_url}/partner/v2/info/", timeout=TIMEOUT),
        {200},
    )
    if environment_header(probe) != "sandbox":
        raise RuntimeError("Refusing write: authenticated endpoint is not sandbox")

    run_id = str(uuid.uuid4())
    company_payload = {
        "name": f"Partner Quickstart {run_id}",
        "onboarding_mode": "api_only",
        "legal_form": "gmbh",
        "address": {"street": "Musterstraße 1", "postal_code": "10115", "city": "Berlin", "country": "DE"},
        "phone": "+49301234567", "tax_treatment": "input_tax_deductible",
        "vat_number": "DE129273398", "default_claim_type": "H05",
        "data_sharing_basis": "self_authorized",
        "payout_bank_account": {"account_holder": f"Partner Quickstart {run_id}", "iban": "DE89370400440532013000", "bic": None},
        "notification_channels": [{"type": "email", "value": f"operations-{run_id}@example.test", "notifications": ["status_updates", "requests_to_client", "statements"]}],
        "legal_representatives": [{"type": "managing_director", "name": "Alex Example"}],
        "users": [{"email": f"admin-{run_id}@example.test", "first_name": "Alex", "last_name": "Example", "role": "admin"}],
    }
    company = checked(session.post(
        f"{base_url}/partner/v2/companies/",
        headers={"Content-Type": "application/json", "Idempotency-Key": str(uuid.uuid4())},
        json=company_payload,
        timeout=TIMEOUT,
    ), {201}).json()
    company_id = company["id"]
    if company.get("case_access") != "available":
        raise RuntimeError("Company does not currently have Case access")
    readiness = company.get("case_submission_readiness", {})
    readiness_summary = {
        "ready": readiness.get("ready") is True,
        "issues": [
            {key: issue.get(key) for key in ("field", "code", "message")}
            for issue in readiness.get("issues", [])
        ],
    }

    debtor_reference = f"partner-quickstart-debtor-{run_id}"
    claim_reference = f"partner-quickstart-claim-{run_id}"
    delegation = {"X-On-Behalf-Of-Company": company_id}
    debtor_payload = {
        "your_reference": debtor_reference, "acting_as": "consumer",
        "person": {"salutation": "mx", "first_name": "Taylor", "last_name": "Debtor"},
        "addresses": [{"street": "Example Street 12", "postal_code": "10115", "city": "Berlin", "country": "DE", "primary": True}],
    }
    debtor = checked(session.post(
        f"{base_url}/v2/debtors/",
        headers={**delegation, "Content-Type": "application/json", "Idempotency-Key": str(uuid.uuid4())},
        json=debtor_payload,
        timeout=TIMEOUT,
    ), {201}).json()
    debtor_id = str(uuid.UUID(debtor["id"]))
    order_payload = {
        "debtor_id": debtor_id,
        "additional_debtor_ids": [], "starting_approach": "extrajudicial",
        "creditor_obligation_fulfilled": True,
        "claims": [{
            "type": "receivable",
            "your_reference": claim_reference, "document_reference": f"INV-{run_id}",
            "subject_matter": "Consulting services for June 2026",
            "principal_amount": {"value": "125.50", "currency": "EUR"},
            "document_date": "2026-06-30", "due_date": "2026-07-14", "is_disputed": False,
            "items": [], "additional_charges": [], "reminders": [], "documents": [],
            "legal_basis": {"claim_type_code": "H05", "contract_date": "2026-06-01", "description": "Consulting agreement"},
        }],
    }
    order = checked(session.post(
        f"{base_url}/v2/orders/",
        headers={
            **delegation,
            "Content-Type": "application/json",
            "Idempotency-Key": str(uuid.uuid4()),
        },
        json=order_payload,
        timeout=TIMEOUT,
    ), {201}).json()
    order_id = order["id"]
    matching_claims = [claim for claim in order.get("claims", []) if claim.get("your_reference") == claim_reference]
    if len(matching_claims) != 1:
        raise RuntimeError("Expected exactly one claim with the submitted business reference")
    claim_id = str(uuid.UUID(matching_claims[0]["id"]))
    if order.get("status") != "draft":
        raise RuntimeError("Created order is not a draft")

    current_company = checked(session.get(
        f"{base_url}/partner/v2/companies/{company_id}/", timeout=TIMEOUT
    ), {200}).json()
    if current_company.get("id") != company_id:
        raise RuntimeError("Company detail response has the wrong identity")

    current_order = checked(session.get(
        f"{base_url}/v2/orders/{order_id}/",
        headers=delegation,
        timeout=TIMEOUT,
    ), {200}).json()
    if current_order.get("id") != order_id or current_order.get("status") != "draft":
        raise RuntimeError("Delegated order detail does not match the created draft")

    return {
        "company_id": company_id,
        "order_id": order_id,
        "claim_id": claim_id,
        "readiness": readiness_summary,
    }


WORKFLOW_RESULT = main()
```

The workflow always stops at the valid draft boundary. Inspect
`WORKFLOW_RESULT["readiness"]`; only a later finalization is gated on
`ready == true`. No secret, authorization header, or credential is printed.
For a production submission flow, resolve all readiness issues and then follow
[Submit cases for a company](/api-docs/partner-api/workflows/submit-cases-for-a-company).

## Related reference

Acceptance events are at least-once change signals. Match each stored claim UUID
against `claim_ids`, then refetch `/v2/claims/{claim_id}/`. Trust the claim's
current `order_id` and `mandate_id` even if the event names a different order
than the one originally submitted; do not reconstruct an order merge chain.

* [GET `/partner/v2/info/`](/api-docs/partner-api/reference/meta/get-partner-token-info)
* [POST `/partner/v2/companies/`](/api-docs/partner-api/reference/companies/onboard-a-company)
* [GET `/partner/v2/companies/{id}/`](/api-docs/partner-api/reference/companies/get-a-managed-company)
* [POST `/v2/orders/`](/api-docs/case-management-api/reference/orders/create-order)
* [GET `/v2/orders/{id}/`](/api-docs/case-management-api/reference/orders/get-order)


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