Update Table Data
Update Table Data
This API allows you to batch update specified records in Agent database tables, with a maximum of 100 records per request.
Note:
The entire JSON request body (request body) size limit is 5MB.
Each request can update up to 100 records.
Request Method
POST
Request URL
https://api.${endpoint}gptbots.ai/v2/database/update/record
Authentication
For authentication details, please refer to the API Overview.
Request
Request Example
curl -X POST 'https://api-${endpoint}gptbots.ai/v2/database/update/record' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"table_id": "673af861ed69656ac0895b07",
"is_create": true,
"update_data":[
{
"record_id":"123456",
"updated_fields": {
"name": "andy",
"age": "30"
}
},
{
"filter": {
"id": "789"
},
"updated_fields": {
"name": "mop",
"age": "32"
}
}
]
}'
curl -X POST 'https://api-${endpoint}gptbots.ai/v2/database/update/record' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
"table_id": "673af861ed69656ac0895b07",
"is_create": true,
"update_data":[
{
"record_id":"123456",
"updated_fields": {
"name": "andy",
"age": "30"
}
},
{
"filter": {
"id": "789"
},
"updated_fields": {
"name": "mop",
"age": "32"
}
}
]
}'
Dieser Codeblock im schwebenden Fenster
Request Headers
| Field | Type | Description |
|---|---|---|
| Authorization | Bearer ${API Key} | Authentication using Authorization: Bearer ${API Key}. Obtain your API key from the API Keys page. |
| Content-Type | application/json | Data format, must be application/json. |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| table_id | string | Yes | Table ID. |
| is_create | bool | No | Whether to create a new record when the specified target record does not exist. |
| update_data | list | Yes | The collection of data to update. |
| record_id | string | No | Either record_id or filter must be provided. record_id is recommended. |
| filter | map | No | User-defined filter condition. Must include a field with "unique": true. Only one field is supported. |
| updated_fields | list | Yes | The collection of fields to update. |
Note
- Either
record_idorfiltermust be provided. When both are passed,record_idtakes precedence.- Default value of
is_createisfalse.- When
is_createis not provided, no new record will be created automatically.- When
is_createis set totrue, if therecord_idorfilterof a record to be updated does not exist in the data table, the record will be automatically created.
Response
Response Example
{
"totalCount": 4,
"success_count": 2,
"fail_count": 2,
"fail_detail": [
{
"upsert_data": {
"record_id": "123456",
"value": {
"name": "test user",
"email": "invalid_email"
}
},
"fail_reason": "Invalid email format"
},
{
"upsert_data": {
"filter": {
"id": "789"
},
"value": {
"name": "test user",
"email": "invalid_email"
}
},
"fail_reason": "Invalid email format"
}
]
}
{
"totalCount": 4,
"success_count": 2,
"fail_count": 2,
"fail_detail": [
{
"upsert_data": {
"record_id": "123456",
"value": {
"name": "test user",
"email": "invalid_email"
}
},
"fail_reason": "Invalid email format"
},
{
"upsert_data": {
"filter": {
"id": "789"
},
"value": {
"name": "test user",
"email": "invalid_email"
}
},
"fail_reason": "Invalid email format"
}
]
}
Dieser Codeblock im schwebenden Fenster
Successful Response
| Field | Type | Description |
|---|---|---|
| totalCount | int | Total number of records in this update operation |
| success_count | string | Number of successfully updated records |
| fail_count | string | Number of failed update operations |
| fail_detail | array | Detailed information about failed updates |
| upsert_data | array | Request data for this failed update operation |
| fail_reason | array | Reason for the update failure |
Error Response
| Field | Type | Description |
|---|---|---|
| code | int | Error code |
| message | string | Error message description |
Error Codes
| Code | Message |
|---|---|
| 40000 | Invalid parameters |
| 50000 | Internal system error |
| 403106 | Table not found |
| 403131 | No permission to access table |
