APICompany

Upsert a company's location

POST
/public/v1/companies/{id}/locations

Upsert a single location of one of the companies in your CRM — one POST handles both create and update. Include an existing location id in the body to update that location, or omit id to create a new one. The create path returns 201 and the update path returns 200; either way the response body is the full location, including its geocoded latitude/longitude. The location also appears in the company's locations array on the company endpoints; it is not returned by GET /public/v1/locations, which lists only your own company's locations.

This endpoint only manages the locations of your partner companies: the {id} in the path must be a company in your CRM other than your own company. To manage your own company's locations, use POST /public/v1/locations instead.

latitude and longitude cannot be sent — they are derived by geocoding the address, because Distru uses these coordinates to generate directions for transfer templates and to optimize delivery routes. Since those features require coordinates, an address that cannot be geocoded is rejected: nothing is saved and the request returns 400 (correct the address fields and retry). If the geocoding service itself is temporarily unavailable the request returns 503 — the address may be fine; retry later. Previously geocoded addresses resolve without contacting the geocoding service.

Updates are sparse: only the fields you send are changed, any field you omit keeps its current value, and sending null for a nullable field clears it (a required field rejects null with a 400). Changing any address field re-geocodes the location and refreshes its coordinates.

Required permission: companies_permissions_create to create a location, companies_permissions_edit to update an existing one.

Authorization

Bearer
headerAuthorizationBearer <token>

API token generated in Distru (Settings → Distru API). Send it on every request as Authorization: Bearer YOUR_API_TOKEN.

Path Parameters

id*string

ID of the company (as returned by GET /public/v1/companies) the location belongs to. Must be a company in your CRM other than your own company; an ID that doesn't exist for your company returns 404, and one your team restrictions hide returns 403.

Request Body

application/json
  1. body
id?string

ID of the location. Provide it to update that location — it must belong to the company in the path and not be soft-deleted, otherwise the request returns 404. Omit it to create a new location.

name?string

Display name of the location. Required on create; cannot be set to null. Characters with diacritics are replaced with their closest ASCII equivalent (e.g. Española becomes Espanola).

street_address?string

Street address (e.g. 1234 Mission St). Required on create; cannot be set to null. Part of the geocoded address.

apt?string

Apartment, suite, or unit within the street address, or null to clear it. Optional.

city?string

City of the address. Required on create; cannot be set to null.

state?string

State or region of the address. Required on create; cannot be set to null. When country is US, must be a two-letter US state abbreviation (e.g. CA).

zip?string

Postal code of the address. Required on create; cannot be set to null. When country is US, must be a valid ZIP code (##### or #####-####) whose prefix matches the state.

country?string

Country of the address as an ISO 3166-1 alpha-2 code (e.g. US). Required on create; cannot be set to null. Official country names and common spellings are normalized to their code (e.g. United States becomes US).

license_id?string

ID of a license held by the same company, linking the location to that license, or null to unlink. Optional. A license that doesn't belong to the company in the path is rejected with a 400. Manage the company's licenses via POST /public/v1/companies/{id}/licenses.

Response Body

An updated location

*/*
  1. response

A single location wrapped in a data envelope

data?

A place where inventory is held. This is flexible: it can be a whole site such as a warehouse or store, or a more specific spot like a room or area within one. Has an address and optionally a license.

Example Request
curl -X POST 'https://app.distru.com/public/v1/companies/00000000-0000-0000-0000-0000000001f9/locations' \  -H 'Content-Type: application/json' \  -d '{  "city": "San Francisco",  "country": "US",  "name": "SF Warehouse",  "state": "CA",  "street_address": "1234 Mission St",  "zip": "94103"}'
Example Response
{  "data": {    "address": "1234 Warehouse Street, Oakland, CA",    "apt": "string",    "city": "string",    "company": {      "id": "3f128a34-cc59-4b49-8883-23bf10e59c6c",      "name": "Retailer 1",      "tasks": [        {          "due_datetime": "string",          "id": "string",          "name": "string",          "status": "ACTIVE"        }      ],      "updated_datetime": "string"    },    "country": "string",    "deleted_at": "string",    "id": "02c88a3f-d759-4973-88f9-60049d682524",    "inserted_datetime": "string",    "latitude": 0,    "license": {      "active": true,      "expiry_datetime": "string",      "id": "02c88a3f-d759-4973-88f9-60049d682524",      "inserted_datetime": "string",      "issue_datetime": "string",      "license_number": "C11-1234567890",      "license_type": "string"    },    "license_id": "02c88a3f-d759-4973-88f9-60049d682524",    "longitude": 0,    "metrc_id": 0,    "name": "Warehouse 1",    "state": "string",    "street_address": "string",    "updated_datetime": "string",    "zip": "string"  }}