Company

Upsert a company's location

Changed on

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.

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

Request

  • Base URL
    https://app.distru.com
  • Auth
    HTTP bearer

Path parameters

idstring required

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

idstring

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.

namestring

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_addressstring

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

aptstring

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

citystring

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

statestring

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).

zipstring

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.

countrystring

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_idstring

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

An updated location

Example response

{
  "data": {
    "address": "1234 Warehouse Street, Oakland, CA",
    "company_id": "02c88a3f-d759-4973-88f9-60049d682524",
    "id": "02c88a3f-d759-4973-88f9-60049d682524",
    "license": {
      "id": "02c88a3f-d759-4973-88f9-60049d682524",
      "license_number": "C11-1234567890"
    },
    "license_id": "02c88a3f-d759-4973-88f9-60049d682524",
    "name": "Warehouse 1"
  }
}

Changes