---
title: "Update an operation unit by external code"
method: PUT
path: "/os/v1/operation-units/external/{externalCode}"
tags: ["Operation Unit", "Operation Unit"]
---

# Update an operation unit by external code

`PUT /os/v1/operation-units/external/{externalCode}`

Updates an operation unit identified by `externalCode` in the URL path.

**Public contract:** parent is nested as `parent.externalCode` (not a root `externalCodeParent`). Send `parent: null` or `parent: ""` to clear the parent; if `parent` is an object, `externalCode` must be a non-empty string (null, empty string, or omitting `externalCode` is invalid).

**Errors:** `404` not found for path code; `409` duplicate body `externalCode` or invalid parent reference (e.g. self-parent); `422` parent external code not found.

## Path parameters

- `externalCode` string, required

## Request body

- UpdateOperationUnitByExternalCodeRequestDto
  - `externalCode` string, required
  - `name` string, required
  - `address` string, nullable, required — Use null or empty string to clear
  - `businessRegistrationNumber` string, nullable, required — CNPJ; use null or empty string to clear
  - `parent` UpdateOperationUnitByExternalCodeParentInputDto, required
    - `externalCode` string, required — Parent operation unit external code. Required when `parent` is an object. To clear the parent, send `parent: null` on the request body (do not use null or empty string here).

## Response `200`

Operation unit updated successfully

## Other responses

- `400` — Bad Request — validation errors (e.g. ValidationPipe), or invalid CNPJ / `businessRegistrationNumber` (Business registration number needs to be a valid cnpj number).
- `401` — Unauthorized - Invalid or missing token
- `404` — No operation unit was found for the given external code in this company
- `409` — Another operation unit in the company already uses this external code, or An operation unit cannot be its own parent
- `422` — No operation unit exists for the company with the parent external code provided
- `500` — Internal Server Error - Unexpected failure

---

[API](https://skmtc.net/gupy/apis/gupy-public-api.md) · [All operations](https://skmtc.net/gupy/apis/gupy-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gupy/gupy-public-api/revisions/3f26defa2a42/schema)
