---
title: "Replace an asset"
method: PUT
path: "/assets/workorders/{workorderId}/attach"
tags: ["Assets"]
---

# Replace an asset

`PUT /assets/workorders/{workorderId}/attach`

## Request

- Base URL: `https://sb2api.servicechannel.com/v3`
- URL: `https://sb2api.servicechannel.com/v3/assets/workorders/{workorderId}/attach`
- Auth: OAuth 2
  - Authorization code: `https://sb2login.servicechannel.com/oauth/authorize`
  - Token URL: `https://sb2login.servicechannel.com/oauth/token`
- TypeScript: <https://skmtc.dev/servicechannel/apis/servicechannel-api-v-3/docs/assets/workorders/:workorderId/attach/put.ts> (a function with typed inputs; its response is checked against the schema)

Replaces one asset with another for the specified work order, or when the work order has no asset, attaches it.  
            <br />Successful response returns `AssetId` and information about asset validation. 
            <br />***Note***: A work order and an asset should belong to the same trade and location.
            <br />***Note***: This method cannot be used if a work order has more than one asset attached.

## Path parameters

- `workorderId` integer, required

## Request body

- ServiceChannelServicesMessagingAssetsAttachAssetRequest
  - `AssetId` integer: Unique numeric identifier of the asset you want to attach to a work order.

## Response `200`

The ID of the asset attached to the work order is in the response.

- ServiceChannelServicesMessagingAssetsAttachAssetResponse: Asset information related to the asset being attached to a work order
  - `AssetId` integer: ID of the asset that was attached to the work order
  - `ValidationRequired` boolean: Indicates whether or not this asset requires validation
  - `AssetValidated` boolean: The current validation status of this asset

## Other responses

- `400`: The request is not accepted due to bad syntax, missing parameters, insufficient data, etc. <br/>Error codes: 502 — Asset is not found or Asset Location/Trade does not correspond to WO Location/Trade 502 — Work order is not found
- `401`: The request is not authorized. <br/>Error codes: 504 — API call rejected by security permissions
- `403`: You are not authorized to request this resource, or the resource is unavailable for some reason. <br/>Error codes: 100 — Current Asset has already been assigned to the work order RecId: workorderId 100 — Work Order either has connection with a leak record or is a Leak Inspection.
- `500`: The server was unable to complete the request due to an internal error. <br/>Error codes: 501 — Object reference is not set to an instance of an object

---

[API](https://skmtc.dev/servicechannel/apis/servicechannel-api-v-3.md) - [All operations](https://skmtc.dev/servicechannel/apis/servicechannel-api-v-3/llms.txt) - [OpenAPI document](https://skmtc.dev/servicechannel/apis/servicechannel-api-v-3/revisions/d490d6596809?raw)
