Quickstart

Create a sandbox API key, verify it, and write your first catalogue item.

This guide takes you from nothing to a working, authenticated call against the Open Network API.

1. Create a sandbox key#

  1. Sign in to the Partner Portal and open Open Network → API keys.
  2. Choose Create key, pick the Sandbox environment, and grant the scopes you need. For this guide, grant REGISTRATION and INVENTORY.
  3. Copy the key. It is shown once — Localoy stores only a hash of it.

A sandbox key looks like this:

Key format
lok_sbx_ab3kq7mz_Hk2m9vQp4XrT7wLs1yNc8dBf6gJz0aUe3iOq5tRw2xE

Keep keys on your server

An API key is a password for your business. Never put it in a browser, a mobile app, or a public repository. The API does not allow cross-origin browser calls.

2. Set up your environment#

Keep the key and the base URL in environment variables. Every example on this site reads them from there.

Shell
export LOCALOY_API_KEY="lok_sbx_…"
export LOCALOY_BASE_URL="https://…/api/v1/open-network/v1"

The base URL is https://api-host.localoy.app/api/v1/open-network/v1. Sandbox and production use the same base URL — the key decides the environment.

3. Verify the key#

Call GET /ping. It needs no scope and tells you which environment and scopes the key carries.

curl "$LOCALOY_BASE_URL/ping" \
  -H "Authorization: Bearer $LOCALOY_API_KEY"
Response · 200
{
  "success": true,
  "data": {
    "ok": true,
    "principal": "PARTNER",
    "environment": "SANDBOX",
    "scopes": ["REGISTRATION", "INVENTORY"],
    "keyPrefix": "lok_sbx_ab3kq7mz"
  }
}

A 401 with open_network_key_invalid means the key was mistyped, revoked or expired. See Authentication.

4. Write a catalogue item#

Send an item keyed by your own ID. Sending the same externalId again updates it instead of creating a duplicate.

cURL
curl -X POST "$LOCALOY_BASE_URL/catalog/items" \
  -H "Authorization: Bearer $LOCALOY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "externalId": "sku-4471",
    "name": "Kacchi Biryani (full)",
    "priceCents": 45000,
    "currency": "BDT",
    "stock": 12
  }'

The first call answers 201 Created; the same call again answers 200 with "message": "Catalog item updated".

5. Read it back#

This needs the INVENTORY scope.

cURL
curl "$LOCALOY_BASE_URL/catalog/items/sku-4471" \
  -H "Authorization: Bearer $LOCALOY_API_KEY"

Next steps#