---
title: "/Endpoint/rest/api/v1/User/{Id}/Department"
slug: "endpointrestapiv1useriddepartment"
updated: 2024-12-18T10:21:11Z
published: 2024-12-18T10:21:11Z
canonical: "docs.agilenow.io/endpointrestapiv1useriddepartment"
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agilenow.io/llms.txt
> Use this file to discover all available pages before exploring further.
# /Endpoint/rest/api/v1/User/{Id}/Department
Post/Endpoint/rest/api/v1/User/{Id}/Department
Use the `DepartmentPost` object resource to insert or update (Upsert) `Department` using `Id, UserId.Email, UserId.Username` field(s) value.
You can supply the required field values in the request data, and then use the `POST` method of the resource.
The input parameter must be used in the `DepartmentData` record structure inside the `FieldType` parameter in the foreign key fields.
Foreign key fields are: `DepartmentId, UserId, ModifiedBy, CreatedBy`
### Update a record of Department
- If the `Id` field value is not matched, then a `404` error is reported (`Errors/Not Found`), and the error record is returned.. You cannot change `Id` field value (primary key).
- If the `UserId.Email, UserId.Username` field value is not empty and `Id` field value is empty, action try insert record according `UserId.Email, UserId.Username` field value (if set, the value is a unique identifier).
### Create a new record of Department
- If the value in the `UserId.Email, UserId.Username` and `Id` fields are empty then action insert a new record according input parameter entity record structure (`DepartmentData`).
The response body will contain the object of the updated or created record if the call is successful. Method returns an extended `Department` structure. Here, all foreign key fields are abstract object structures, utilizing `AbstractText` or `AbstractLong` data types, offering a detailed view of the data and related entities.
SecurityOAuth
oAuth autentication flow
FlowClient Credentials Token URLhttps://dev.esystems.fi/oAuth/rest/v2/Token
Refresh URLhttps://dev.esystems.fi/oAuth/rest/v2/Token
Path parametersIdstringRequired
The identifier of the User record. The parameter is part of the url address and some special characters are forbidden.
You can extract any string to a base64 string. E.g email address name@domain.com value is base64|bmFtZUBkb21haW4uY29t
Query parametersNamestring
The name of the database field. If empty, the entity `Id` field is used.
Example:
```
Id
```
Body parameters
`Department` information to insert or update.
The input parameter must be used in the `DepartmentData` record structure inside the `FieldType` parameter in the foreign key fields.
Expand Allobject
The record of Department information.
DepartmentIdobject (FieldType)
The field object structure. This structure allows users to specify any related entity field and its corresponding value. When saving data, the system automatically retrieves and assigns the primary key value from the system database table based on the provided field name and value.
Fieldstring
The name of the data field. This can be any field name from the related database table, such as 'Email' from the User table or 'Name' from the Department table.
Valuestring Required
The value corresponding to the specified data field. This value is used to identify the record in the related database table. For example, it could be an email address, a department name, or an external system's identifier.
Responses200
Inserted or updated `Department` information.
Expand Allobject
The record of Department information.
Idstring
The guid to identify the department
ExternalIdstring
The external identifier of the department
Namestring
The name of the department
DepartmentTypeIdobject (AbstractText)
This structure represents an abstract object with a primary key of type Text. It is used to encapsulate detailed information about related entities.
Idstring
The primary key of the record. It uniquely identifies each record within the dataset. This attribute is required and must be unique across all records.
Example3ad64ab3-bd04-46c5-b1d7-c0b34be9e5b5
ExternalIdstring
An external identifier for the record, which can be used to link the record to external systems or datasets. This attribute is optional but should be unique if provided.
Example3ad64ab3-bd04-46c5-b1d7-c0b34be9e5b5
Namestring
The name of the record. This attribute provides a human-readable identifier for the record, making it easier to recognize and differentiate records in lists or other displays. This attribute is optional.
ExampleBob Normal
Typestring
The type of the record object. This attribute is used to classify the record into specific categories or types, helping to organize and manage different kinds of records. This attribute is optional.
ExampleUser
ParentDepartmentIdobject (AbstractText)
This structure represents an abstract object with a primary key of type Text. It is used to encapsulate detailed information about related entities.
Idstring
The primary key of the record. It uniquely identifies each record within the dataset. This attribute is required and must be unique across all records.
Example3ad64ab3-bd04-46c5-b1d7-c0b34be9e5b5
ExternalIdstring
An external identifier for the record, which can be used to link the record to external systems or datasets. This attribute is optional but should be unique if provided.
Example3ad64ab3-bd04-46c5-b1d7-c0b34be9e5b5
Namestring
The name of the record. This attribute provides a human-readable identifier for the record, making it easier to recognize and differentiate records in lists or other displays. This attribute is optional.
ExampleBob Normal
Typestring
The type of the record object. This attribute is used to classify the record into specific categories or types, helping to organize and manage different kinds of records. This attribute is optional.
ExampleUser
HierarchicalNamestring
The hierarchical name of the department
Levelinteger (int32)
The department level at the hierarchy
Default0Example0
ContactNamestring
The contact name of company or department
ContactEmailstring
The contact email of external company or department
ContactPhonestring
CountryIdobject (AbstractText)
This structure represents an abstract object with a primary key of type Text. It is used to encapsulate detailed information about related entities.
Idstring
The primary key of the record. It uniquely identifies each record within the dataset. This attribute is required and must be unique across all records.
Example3ad64ab3-bd04-46c5-b1d7-c0b34be9e5b5
ExternalIdstring
An external identifier for the record, which can be used to link the record to external systems or datasets. This attribute is optional but should be unique if provided.
Example3ad64ab3-bd04-46c5-b1d7-c0b34be9e5b5
Namestring
The name of the record. This attribute provides a human-readable identifier for the record, making it easier to recognize and differentiate records in lists or other displays. This attribute is optional.
ExampleBob Normal
Typestring
The type of the record object. This attribute is used to classify the record into specific categories or types, helping to organize and manage different kinds of records. This attribute is optional.
ExampleUser
Is_Activeboolean
Defines if the department is active and can be used
DefaultfalseExampleFalse
ModifiedOnstring (date-time)
The date the record was updated
Default"1900-01-01T12:00:00Z"Example1900-01-01T12:00:00Z
CreatedOnstring (date-time)
The date the record was created
Default"1900-01-01T12:00:00Z"Example1900-01-01T12:00:00Z
400
Bad Request - The user has provided input that the browser is unable to convert.
```json
{
"Errors": [
"The user has provided input that the browser is unable to convert.",
"There are multiple rows in the database for the same value",
"The value does not match the specified entity structure",
"..."
],
"Type": "/Errors/Bad Input",
"Title": "Bad Request",
"StatusCode": 400,
"Instance": "/OpenApi/rest/Xzy",
"RequestKey": "894ea43c-b8a6-4195-9a9c-82c07d9cc33a"
}
```
object
The list of errors. Throw specific exceptions based on the received error.
Errors Array of string
Human-readable explanation of the errors
string Default""
Typestring
URI identifier that categorizes the error
Default""
Titlestring
Brief, human-readable message about the error
Default""
StatusCodeinteger (int32)
The HTTP response code
Example400
Instancestring
URI that identifies the specific occurrence of the error
Default""
RequestKeystring
Provides a request key that identifies the current request.
Default""
401
Unauthorized - The response status code indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource.
```json
{
"Errors": [
"The session Id or OAuth token used has expired or is invalid."
],
"Type": "/Errors/Unauthorized",
"Title": "Unauthorized",
"StatusCode": 401,
"Instance": "/OpenApi/rest/Xzy",
"RequestKey": "894ea43c-b8a6-4195-9a9c-82c07d9cc33a"
}
```
object
The list of errors. Throw specific exceptions based on the received error.
Errors Array of string
Human-readable explanation of the errors
string Default""
Typestring
URI identifier that categorizes the error
Default""
Titlestring
Brief, human-readable message about the error
Default""
StatusCodeinteger (int32)
The HTTP response code
Example400
Instancestring
URI that identifies the specific occurrence of the error
Default""
RequestKeystring
Provides a request key that identifies the current request.
Default""
403
Forbidden - The user does not have access to execute operation
```json
{
"Errors": [
"The user does not have access to execute operation"
],
"Type": "/Errors/Permission",
"Title": "Bad Request",
"StatusCode": 403,
"Instance": "/OpenApi/rest/Xzy",
"RequestKey": "894ea43c-b8a6-4195-9a9c-82c07d9cc33a"
}
```
object
The list of errors. Throw specific exceptions based on the received error.
Errors Array of string
Human-readable explanation of the errors
string Default""
Typestring
URI identifier that categorizes the error
Default""
Titlestring
Brief, human-readable message about the error
Default""
StatusCodeinteger (int32)
The HTTP response code
Example400
Instancestring
URI that identifies the specific occurrence of the error
Default""
RequestKeystring
Provides a request key that identifies the current request.
Default""
500
Internal Server Error - An internal server error is an error on the web server you're trying to access.
```json
{
"Errors": [
"An internal server error is an error on the web server you're trying to access."
],
"Type": "/Errors/Internal Server Error",
"Title": "Internal Server Error",
"StatusCode": 500,
"Instance": "/OpenApi/rest/Xzy",
"RequestKey": "894ea43c-b8a6-4195-9a9c-82c07d9cc33a"
}
```
object
The list of errors. Throw specific exceptions based on the received error.
Errors Array of string
Human-readable explanation of the errors
string Default""
Typestring
URI identifier that categorizes the error
Default""
Titlestring
Brief, human-readable message about the error
Default""
StatusCodeinteger (int32)
The HTTP response code
Example400
Instancestring
URI that identifies the specific occurrence of the error
Default""
RequestKeystring
Provides a request key that identifies the current request.
Default""