Skip to main content
PATCH
← Purchases API Give suppliers you already have their activity code (CNAE or SIC), which picks the spend-based emission factor of their purchases: the suppliers Create Purchases (v2) created in_progress from a supplier_name it did not know, the ones created in the app, or one Create Purchase Suppliers (v2) rejected with SUPPLIER_ALREADY_EXISTS. The request checks every record, gives each supplier its code at once and answers 202 Accepted with an ingest job that recalculates their purchases in the background (see how bulk ingestion works). Follow it with GET /v2/ingest-jobs/{id} or, for a job submitted with an API key, the ingest_job.finished webhook.
Beta. Part of the bulk ingest API, in beta. The contract may still change before general availability.

How it works

  1. Every record is checked: its supplier exists and is in your organization’s perimeter, it is not already in the request, and its code is an active code of its framework, as in Create Purchase Suppliers (v2). If any record is invalid the whole request is rejected with 422 and nothing is written (all or nothing).
  2. Every supplier takes its code at once, in one transaction: it is active, and a classification Dcycle had found for it (D&B) is replaced by yours, as the Data Importer’s supplier codes import does. Its name and country do not change.
  3. The job recalculates the purchases of each supplier, in the supplier’s own organization: they go back to in_progress, without emissions, and are calculated again with the factor of the new activity, whatever their status was (an error one included). A supplier sent with the code it already has is recalculated too, so send only the suppliers whose code you want to set or change.
  4. When every chunk is done the job is completed (or completed_with_errors). For a job submitted with an API key, ingest_job.finished is sent with "operation": "update" to the webhook endpoints of the x-organization-id organization.
The job is done when the purchases are queued for their calculation, not when it ends: for a supplier with many purchases they can stay in_progress for some minutes after the job is completed. Read them with List Purchases.

Request

Headers

string
required
Your API key (see Authentication).
string
required
The organization the suppliers are classified for. Its suppliers, and those of the organizations under it that you can write to (its perimeter), can be classified.
string
required
1 to 255 characters, one per batch, looked up per organization across every v2 bulk route. Within 24 hours, the same key with the same route and body returns the original job (with Idempotent-Replayed: true); the same key with another body or on another route is 422 IDEMPOTENCY_KEY_REUSED, and while the first request is still being processed 409 IDEMPOTENCY_KEY_IN_PROGRESS. After 24 hours the key is free, and a request with it is a new one. See The Idempotency-Key.

Query Parameters

boolean
default:"false"
Check only: the same 422 for invalid records, nothing written, no job; 200 with {"dry_run": true, "submitted": n, "valid": n} when every record is valid. The Idempotency-Key header is still required, but a dry run does not check or store it.

Body Parameters

array[object]
required
The suppliers to classify, 1 to 1,000. A field not listed here is rejected (SCHEMA_INVALID).

Response

202 Accepted with the job (entity_type: purchase_suppliers, operation: update) and a Location header to it. GET /v2/ingest-jobs/{id}/items has one item per supplier, in the order sent, with the supplier’s id as entity_id; an item is failed with CALCULATION_FAILED when the supplier was deleted before the job reached it, or its purchases could not be queued.

Errors

Problem details. Per-record codes in errors[].error_code of a 422 BULK_RECORDS_REJECTED: Request-level errors: 401 for a missing or invalid API key, 403 LOGGED_USER_NOT_MEMBER when the key’s user is not a member of the organization, 422 REQUEST_VALIDATION_FAILED for a malformed body (no records, more than 1,000, no Idempotency-Key), 422 IDEMPOTENCY_KEY_REUSED, 409 IDEMPOTENCY_KEY_IN_PROGRESS, and 429 beyond the rate limits.

Limits

Create Purchase Suppliers (v2)

Create new suppliers, with their code

List Purchase Suppliers

Find the ids to classify

Create Purchases (v2)

Purchases from these suppliers

Get Ingest Job

Follow the recalculation