Skip to content

Update City

Update an existing city. Requires authentication.

Endpoint

PUT /v1/accounts/city/?id={city_id}

Authentication

Required

Query Parameters

Parameter Type Required Description
id integer Yes City ID

Request Body

Form data (multipart/form-data):

Field Type Required Description
name string No City name (optional, only updates if provided)
country_id integer No Country ID (optional, only updates if provided)

Response

Success (200 OK)

{
  "id": 1,
  "name": "Baku",
  "country_id": 1,
  "country": {
    "id": 1,
    "name": "Azerbaijan",
    "created": "2025-01-15T10:30:00Z"
  },
  "created": "2025-01-15T10:30:00Z"
}

Error Responses

Not Found (404)

{
  "error": "City not found"
}

or

{
  "error": "Country not found"
}

Missing ID Parameter (400)

{
  "message": "Param not send!"
}

Bad Request (400)

{
  "error": "Invalid country ID"
}

Unauthorized (401)

{
  "error": "Missing token on header!"
}

Internal Server Error (500)

{
  "error": "Failed to update city"
}

Example Request

curl -X PUT "https://api.luxmart.site/v1/accounts/city/?id=1" \
  -H "Authorization: Token your_access_token" \
  -F "name=Baku" \
  -F "country_id=1"

Notes

  • Only updates fields that are provided in the request
  • Both name and country_id are optional - if not provided, they remain unchanged
  • If country_id is provided, it must reference an existing, non-deleted country
  • The updated timestamp is automatically set by the system
  • Returns 404 if city or country is not found or has been deleted