Create Supplier
This endpoint creates a supplier and returns the generated supplier ID.
Endpoint
Section titled “Endpoint”POST /v1/suppliers/suppliersAuthentication
Section titled “Authentication”Include your API key in the x-api-key header. See Authentication.
Required Scope
Section titled “Required Scope”suppliers:writeRequest Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Supplier name. If it is missing, the API returns 500. |
description | string | No | Supplier description. Stored as null when omitted. |
Example Request Body
Section titled “Example Request Body”{ "name": "Supplier Name", "description": "A brief description of the supplier"}Example Request
Section titled “Example Request”curl -X POST "https://api.crewsum.com/v1/suppliers/suppliers" \ -H "x-api-key: $CREWSUM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Supplier Name", "description": "A brief description of the supplier" }'const response = await fetch("https://api.crewsum.com/v1/suppliers/suppliers", { method: "POST", headers: { "x-api-key": process.env.CREWSUM_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ name: "Supplier Name", description: "A brief description of the supplier", }),});const result = await response.json();POST /v1/suppliers/suppliers HTTP/1.1Host: api.crewsum.comx-api-key: <your-api-key>Content-Type: application/json
{ "name": "Supplier Name", "description": "A brief description of the supplier"}Response
Section titled “Response”On success, the API returns HTTP 201 Created.
Example Response
Section titled “Example Response”{ "message": "Successfully created supplier: supplier-stu123vwx4567890", "data": { "supplierId": "supplier-stu123vwx4567890" }}Behavior
Section titled “Behavior”- The API generates the supplier ID in the format
supplier-<16 hex characters>. - New suppliers are active (
isArchived: false) and haveupdatedAt: null. - The request body is not validated against a schema. Wrong types are stored as sent or cause a
500. - After the supplier is created, Crewsum sends the
suppliers.createdwebhook event. The payload is{ "suppliers": [<supplier>] }.
Error Responses
Section titled “Error Responses”| Status | Meaning |
|---|---|
500 | Crewsum could not create the supplier, for example because name was missing. Message: Error creating supplier. If no request body is sent, the API returns a 500 with a generic error body instead. |
Authentication and scope failures are described in Errors.
Related Webhooks
Section titled “Related Webhooks” suppliers.created View webhook event details.