logo
Desarrollo
Buscar
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"
        }
      ]
    }'

                    
Este bloque de código en una ventana flotante

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 The ID of the target table.
update_data list Yes Collection of records to be updated.
record_id string No Either record_id or filter must be provided. record_id is recommended.
filter map No Custom filter conditions (must use custom unique primary key fields).
is_create bool No Whether to create a new record when the target record does not exist.
updated_fields list Yes Collection of fields to be updated.

Either record_id or filter must be provided, with record_id being the recommended option. When both are provided, record_id takes precedence.
The default value of is_create is false. When is_create is not provided, new records will not 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"
        }
    ]
}

                    
Este bloque de código en una ventana flotante

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