# Update cost allocation

Update cost allocation

## Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/corehr/v2/cost_allocations/update_version
HTTP Method | POST
Rate Limit | [3 per second](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
Supported app types | Custom App、Store App
Required scopes<br>**To use this API, you must have at least 1 of the listed scopes.** | 成本分摊写权限(corehr:cost_allocation:write)
Required field scopes | **Notice**：The response body of the API contains the following sensitive fields, and they will be returned only after corresponding scopes are added. If you do not need the fields, it is not recommended that you request the scopes.<br>Obtain user ID(contact:user.employee_id:readonly)

### Request header

Parameter | Type | Required | Description
---|---|---|---
Authorization | string | Yes | `tenant_access_token`<br>**Value format**: "Bearer `access_token`"<br>**Example value**: "Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[How to choose and get access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | Yes | **Fixed value**: "application/json; charset=utf-8"

### Query parameters

Parameter | Type | Required | Description
---|---|---|---
user_id_type | string | No | User ID categories<br>**Example value**: open_id<br>**Optional values are**:<br>- open_id：Identifies a user to an app. The same user has different Open IDs in different apps. [How to get Open ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-openid)<br>- union_id：Identifies a user to a tenant that acts as a developer. A user has the same Union ID in apps developed by the same developer, and has different Union IDs in apps developed by different developers. A developer can use Union ID to link the same user's identities in multiple apps.[How to get Union ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-union-id)<br>- user_id：Identifies a user to a tenant. The same user has different User IDs in different tenants. In one single tenant, a user has the same User ID in all apps （including store apps）. User ID is usually used to communicate user data between different apps. [How to get User ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-user-id)<br><md-enum-item key="people_corehr_id" ><br>**Default value**: `open_id`<br>**When the value is `user_id`, the following field scopes are required**:<br>Obtain user ID(contact:user.employee_id:readonly)
client_token | string | No | Determine whether the same request is based on whether the client_token are consistent<br>**Example value**: 1245464678<br>**Data validation rules**:<br>- Length range: `0` ～ `128` characters

### Request body

Parameter | Type | Required | Description
---|---|---|---
employment_id | string | Yes | Employee Employment ID<br>**Example value**: "6862995757234914821"
cost_allocation | employment_cost_allocation | No | cost allocation
wk_id | string | Yes | ID<br>**Example value**: "703912325303191204"
effective_time | string | No | Effective time<br>**Example value**: "2024-12-01"
expiration_time | string | No | Expiration time<br>**Example value**: "2024-12-02"
job_data_cost_center_id | job_data_cost_center\[\] | No | cost allocation<br>**Data validation rules**:<br>- Length range: `0` ～ `10000`
cost_center_id | string | No | Cost center ID, you can obtain the corresponding cost center information through the [Query a single cost center information] interface<br>**Example value**: "6950635856373745165"
new_rate | number(float) | No | proportion of assessment<br>**Example value**: 50.2
reason | string | No | Reason for change<br>**Example value**: "异动"

### Request body example
```json
{
    "employment_id": "6862995757234914821",
    "cost_allocation": {
        "wk_id": "703912325303191204",
        "effective_time": "2024-12-01",
        "expiration_time": "2024-12-02",
        "job_data_cost_center_id": [
            {
                "cost_center_id": "6950635856373745165",
                "new_rate": 50.2
            }
        ],
        "reason": "异动"
    }
}
```

## Response

### Response body

Parameter | Type | Description
---|---|---
code | int | Error codes, fail if not zero
msg | string | Error descriptions
data | \- | \-

### Response body example
```json
{
    "code": 0,
    "msg": "success",
    "data": {}
}
```

### Error code

HTTP status code | Error code | Description | Troubleshooting suggestions
---|---|---|---
429 | 1161604 | QPS over limit | Increase the threshold of limited viewership

