Stores - Usage Examples

Last Updated: 2026-07-09

Authentication

# Step 1: Obtain token
curl -s -X POST https://api.djanity.com/auth/login/ \
  -H "Content-Type: application/json" \
  -d '{"username": "[email protected]", "password": "..."}'
# Returns: {"access": "<jwt>", "refresh": "<jwt>"}

# Step 2: All subsequent requests use:
# -H "Authorization: Bearer <token>"

Stores

List all stores

Returns active stores only, default store first, cached for 10 minutes.

curl -s https://api.djanity.com/stores/ \
  -H "Authorization: Bearer <token>"

Response (paginated; each result is the full StoreSerializer object, trimmed here):

{
  "count": 3,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": "0f0e7a1c-1111-4a4a-9c9c-aaaaaaaaaaaa",
      "sanity_id": "store-london-flagship",
      "store_code": "LON001",
      "slug": "london-flagship",
      "name": "London Flagship",
      "is_active": true,
      "is_default": true,
      "tax_rate": 0.2,
      "settings": {
        "isActive": true,
        "timezone": "Europe/London",
        "defaultCurrency": "GBP",
        "acceptsOnlineReturns": true,
        "requiresAppointments": false
      },
      "regulatedCompliance": null
    }
  ]
}

Retrieve a store (summary shape)

Retrieve returns the StoreService.get_store_summary() payload, not the full serializer object. The lookup value can be a store_code, Django UUID, or Sanity ID.

curl -s https://api.djanity.com/stores/LON001/ \
  -H "Authorization: Bearer <token>"

Response:

{
  "id": "0f0e7a1c-1111-4a4a-9c9c-aaaaaaaaaaaa",
  "sanity_id": "store-london-flagship",
  "store_code": "LON001",
  "name": "London Flagship",
  "is_active": true,
  "is_default": true,
  "timezone": "Europe/London",
  "employee_count": 18,
  "active_zones_count": 6,
  "total_zones_count": 8,
  "recent_compliance_checks_count": 14
}

Dashboard home snapshot

curl -s https://api.djanity.com/stores/LON001/dashboard_home/ \
  -H "Authorization: Bearer <token>"

Response schema: Dashboard Home.

Create a store

slug is server-derived; do not send it.

curl -s -X POST https://api.djanity.com/stores/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "store_code": "BIR001",
    "name": "Birmingham New Street",
    "address_data": {
      "street": "12 Corporation Street",
      "city": "Birmingham",
      "state": "West Midlands",
      "postal_code": "B2 4AX",
      "country": "GB"
    },
    "phone": "+44-121-555-0100",
    "default_currency": "GBP",
    "is_active": true,
    "timezone": "Europe/London"
  }'

Response (201 Created): the full store object, with slug set to birmingham-new-street.

Update a store (partial)

Only fields present in the payload change; everything else is preserved.

curl -s -X PATCH https://api.djanity.com/stores/BIR001/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"name": "Birmingham New Street (Flagship)", "phone": "+44-121-555-0199"}'

Make a store the default

Setting is_default clears the flag on every other store automatically.

curl -s -X PATCH https://api.djanity.com/stores/BIR001/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"is_default": true}'

Sites

Site is Django-owned (no Sanity sync). The storefront resolves branding and configuration by domain at SSR time.

Look up a site by domain

curl -s "https://api.djanity.com/sites/?domain=downtown.myshop.com" \
  -H "Authorization: Bearer <token>"

List active sites, default first

curl -s https://api.djanity.com/sites/ \
  -H "Authorization: Bearer <token>"

Tax Jurisdictions

List tax jurisdictions

Returns a bare (unpaginated) array.

curl -s https://api.djanity.com/tax-jurisdictions/ \
  -H "Authorization: Bearer <token>"

Response:

[
  {
    "id": "3b2f6c1a-2222-4b4b-8d8d-bbbbbbbbbbbb",
    "sanity_id": "taxJurisdiction-england",
    "name": "England Standard Rate",
    "tax_rates_data": [
      {"name": "VAT Standard", "rate": 20.0, "isActive": true}
    ],
    "total_rate": "0.2000",
    "effective_date": "2011-01-04",
    "notes": "UK standard VAT rate",
    "is_exempt": false
  }
]

Retrieve by Sanity ID

curl -s https://api.djanity.com/tax-jurisdictions/taxJurisdiction-england/ \
  -H "Authorization: Bearer <token>"

Create a tax jurisdiction

total_rate is auto-calculated from tax_rates_data.

curl -s -X POST https://api.djanity.com/tax-jurisdictions/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "sanity_id": "taxJurisdiction-scotland-reduced",
    "name": "Scotland Reduced Rate",
    "tax_rates_data": [
      {"name": "VAT Reduced", "rate": 5.0, "isActive": true}
    ],
    "effective_date": "2020-03-01",
    "notes": "Applies to certain food and energy products"
  }'

Response (201 Created): includes total_rate: "0.0500".


Compliance Checks

List compliance checks

curl -s https://api.djanity.com/compliance-checks/ \
  -H "Authorization: Bearer <token>"

Retrieve by check ID

curl -s https://api.djanity.com/compliance-checks/CHK-2026-001/ \
  -H "Authorization: Bearer <token>"

Create a compliance check

check_id is client-supplied and must be unique; timestamp is set by the server.

curl -s -X POST https://api.djanity.com/compliance-checks/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "check_id": "CHK-2026-014",
    "zone": "9c8b7a6d-3333-4c4c-9e9e-cccccccccccc",
    "employee": "1a2b3c4d-4444-4d4d-8f8f-dddddddddddd",
    "status": "pass",
    "checklist_results": {
      "cleanliness": {"status": "pass", "score": 10, "notes": "Spotless"},
      "organization": {"status": "pass", "score": 9, "notes": "Minor gap on shelf B2"},
      "safety": {"status": "pass", "score": 10, "notes": "All exits clear"}
    },
    "notes": "Routine weekly inspection, all areas compliant"
  }'

Response (201 Created): the check with its server-set timestamp. The record syncs to Sanity asynchronously.


Was this page helpful?