# Write Api

# Create new Delegated

This endpoint creates a new delegated which is linked to an intermediary .

<p class="callout success"><span style="color: #008000;">**[\[POST\] /api/v1/{itemId}/intermediary/{taxId}/delegated](https://spid-write-dev.agyo.io/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/spid-write-controller/initSpid)**</span></p>

**Reminder** : One intermediary can have many delegates

### Header

Header used on this API are those taken from [header standards of TS Digital.](https://digital-docs.ts-paas.com/books/utilizzo-api-tsdigital/page/linee-guida-generali-api-ts-digital)

`Content-type` is accepted in `application/json`

### Query Parameters

Parameters used to make a successful request.

- **itemId**: Unique personal identification of the item associated with the Intermediary requested. Mandatory for personal or technical users. (<span style="color: #ff0000;">***required***</span>)
- **taxId**: Unique fiscal code of the item associated with Intermediary requested. (<span style="color: #ff0000;">***required***</span>)

### Body

Body request for this endpoint is a JSON in a format described below

```JSON
{
  "taxId": "stringstringstri",
  "firstName": "string",
  "lastName": "string",
  "description": "string"
}
```

- **taxId**: Unique fiscal code of the Delegated which is being requested.
- **firstName**: First name of the item which is requesting Delegated.
- **lastName**: Last name of the item which is requesting Delegated.
- **description**: Description associated with the Delegated which is being processed.

### Response

##### On successful response

If successful, the **API** responds with HTTP code **200(OK)** with the following body:

```JSON
{
  "firstName": "string",
  "lastName": "string",
  "description": "string"
}
```

- **firstName**: First name of the Delegated created.
- **lastName**: Last name of the Delegated created.
- **description**: Description of the Delegated created

##### On error response

In the event of an error, the **API** responds with a body **JSON** with the following format:

```JSON
{
  "code": "string",
  "timestamp": "2022-04-13T13:35:16.678Z",
  "message": "string",
  "subErrors": [
    {}
  ]
}
```

- **code**: A string representation of the HTTP error code, linked with the returned http error
- **timestamp**: Date and time of the answer, expressed as a string.
- **message**: Message expressing error.

Possible errors are:

- **400**: The request is malformed (parameters with incorrect format, invalid or inconsistent parameters).
- **401**: An authorization token has not been provided or the authorization token provided is invalid (eg: it has expired).
- **403**: The provided token is valid, but the user is not authorized to perform the operation.
- **500**: An unexpected error occurred.