Order a Credential
You want to issue a Credential to a person using the Breeze API.
Prerequisites
- A valid access token — see Authentication
- Your Tenant ID — provided by your Breeze administrator along with your API credentials
Step 1 — Find your Template
Before ordering, you need the Template's ID and the list of fields it requires. Call CredentialTemplatesV2 with your Tenant ID.
- curl
- Node.js
curl -X POST https://system.upnxt.no/graphql \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
-d '{
"query": "query GetTemplates($tenantIds: [ID!]!) { CredentialTemplatesV2(tenantIds: $tenantIds) { docs { _id name type_name template_fields { all_used_fields { name field_type } } } } }",
"variables": { "tenantIds": ["tenant_abc123"] }
}'
const response = await fetch('https://system.upnxt.no/graphql', {
method: 'POST',
headers: {
Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `query GetTemplates($tenantIds: [ID!]!) {
CredentialTemplatesV2(tenantIds: $tenantIds) {
docs {
_id
name
type_name
template_fields {
all_used_fields {
name
field_type
}
}
}
}
}`,
variables: { tenantIds: ['tenant_abc123'] },
}),
});
const { data } = await response.json();
Response:
{
"data": {
"CredentialTemplatesV2": {
"docs": [
{
"_id": "template_card123",
"name": "Company ID Card",
"type_name": "TPL_CardCredential",
"template_fields": {
"all_used_fields": [
{ "name": "personFirstName", "field_type": "string" },
{ "name": "personLastName", "field_type": "string" },
{ "name": "personPhoto1", "field_type": "buffer" },
{ "name": "cardValidUntilDate", "field_type": "date" }
]
}
}
]
}
}
}
Note down the _id of the Template you want to use, and the name and field_type of each entry in all_used_fields.
Step 2 — Understand the data fields
Each entry in your data array provides a value for one field. The key you use depends on the field's type:
| Field type | Value key |
|---|---|
string | string_value |
number | number_value |
boolean | bool_value |
date | date_value (ISO 8601: 2035-12-31T12:00:00.000Z) |
buffer | base64_value (Base64 image) or url_value (image URL) |
Use exactly one value key per entry. Providing the wrong key for a field's type will return an error.
See Data fields for the full list of available field names and types.
Step 3 — Submit the order
Call CredentialOrderV1 with your Template ID and data array. In this example the Template requires personFirstName, personLastName, and cardValidUntilDate (date). personPhoto1 is an image field — not manual input, but you can supply it via url_value or base64_value. See Data fields for the image exception.
- curl
- Node.js
curl -X POST https://system.upnxt.no/graphql \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
-d '{
"query": "mutation OrderCredential($credential: CredentialOrderInput!) { CredentialOrderV1(credential: $credential) { _id credential_number } }",
"variables": {
"credential": {
"template_id": "template_card123",
"external_id": "EMP-00412",
"data": [
{ "data_field": "personFirstName", "string_value": "Jane" },
{ "data_field": "personLastName", "string_value": "Smith" },
{ "data_field": "cardValidUntilDate", "date_value": "2029-12-31T12:00:00.000Z" },
{ "data_field": "personPhoto1", "url_value": "https://hr.example.com/photos/jane_smith.jpg" }
]
}
}
}'
const response = await fetch('https://system.upnxt.no/graphql', {
method: 'POST',
headers: {
Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `mutation OrderCredential($credential: CredentialOrderInput!) {
CredentialOrderV1(credential: $credential) {
_id
credential_number
}
}`,
variables: {
credential: {
template_id: 'template_card123',
external_id: 'EMP-00412',
data: [
{ data_field: 'personFirstName', string_value: 'Jane' },
{ data_field: 'personLastName', string_value: 'Smith' },
{
data_field: 'cardValidUntilDate',
date_value: '2029-12-31T12:00:00.000Z',
},
{
data_field: 'personPhoto1',
url_value: 'https://hr.example.com/photos/jane_smith.jpg',
},
],
},
},
}),
});
const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);
- Success
- Error
{
"data": {
"CredentialOrderV1": {
"_id": "cred_abc123",
"credential_number": 1042
}
}
}
{
"errors": [
{
"message": "Field 'cardValidUntilDate' expects a date value",
"extensions": { "code": "BAD_USER_INPUT" }
}
],
"data": null
}
Step 4 — Confirm success
A successful response includes:
_id— the Credential's unique ID. Use this to fetch or update the Credential later.credential_number— the human-readable identifier visible in the Breeze UI.
No further API call is needed. What happens next depends on the Tenant's checkout-flow configuration, reflected in the Credential's status: in_queue (sent directly to the production queue), requested (joins the Tenant's order and checkout process), or waiting_for_approval (an approver must approve it first). See CredentialOrderV1 — Response for details.