Skip to main content

Quickstart

Get your first API call working in minutes.

Prerequisites

Two things must be in place before the API will respond.

1. Enable Dev Mode

In the shop admin, go to Settings and scroll down to Developer Tools. Toggle Developer Mode on. This unlocks the API and reveals the API Keys tab.

2. Generate an API key

Open the API Keys tab and click Generate. A modal opens where you provide a label and the domain your theme is deployed to. Click Generate — the key is shown once, copy it immediately.

Base URL

http://api.dukanext.co.ke/access/api/v1

Store it in an environment variable:

const BASE_URL = process.env.NEXT_PUBLIC_DUKANEXT_BASE_URL;
// http://api.dukanext.co.ke/access/api/v1

Authentication

Every request requires the x-api-key header:

const res = await fetch(`${BASE_URL}/categories`, {
headers: {
"x-api-key": process.env.NEXT_PUBLIC_DUKANEXT_API_KEY,
},
});

When testing in Postman, also set the Host header to the shop's domain. Browsers set this automatically — your theme code does not need to set it.

Response envelope

All successful responses follow this shape:

{
"status": "success",
"data": { ... }
}

Error envelope

All errors follow this shape:

{
"status": "failed",
"message": "Human-readable description",
"code": "MACHINE_READABLE_CODE"
}

Always branch on code in your UI logic, not on message. Codes are stable; messages may change.

See the full Error Codes reference for every possible code.

Next steps

  • Dev Mode — what it unlocks and what breaks without it
  • API Keys — key management and origin allowlists
  • Shop Health Check — the first call every theme must make