Why is the "Created by" always "Administrator" when I add records with API token?

■ Question / Problem

I am adding records to a kintone app from my python program using REST API with API token authentication.The records are created, but the "Created by" (and "Updated by") always shows the user "Administrator".
But it works well when I use my js customization update records without API token in other kintone app.
Is this always the case when I use API tokens?And I want to know if this is something that can be changed or not.

■ Code/Attempts

Here is my python code.:backhand_index_pointing_down:

import requests


def add_record(name):
    url = "https://{mysubdomain}.kintone.com/k/v1/record.json"
    headers = {
        "X-Cybozu-API-Token": "{myAPItoken}",
        "Content-Type": "application/json"
    }
    payload = {
        "app": 1,
        "record": {
            "name": {"value": name}
        }
    }
    response = requests.post(url, headers=headers, json=payload)
    return response.json()
add_record("Alex")

Here is my JS code.:backhand_index_pointing_down:

(() => {

  'use strict';
  const FIELD_CODE = 'User_selection';

  const EVENTS = ['app.record.create.submit.success','app.record.edit.submit.success'];
// ================

  kintone.events.on(EVENTS, async (event) => {
     const srcRecord = event.record;
     const field = {
      type: 'USER_SELECT',
      value: [{ code: srcRecord.Updated_by.value.code }],
  };

  try {
    await kintone.api(kintone.api.url('/k/v1/record.json', true), 'PUT', {
        app: event.appId,
        id: event.recordId,
        record: {
          [FIELD_CODE]: field,
        },
      });
    } catch (error) {
      console.error(error);
    }
  return event;
  });
})();

Hello @kokonuts

Regarding your question, this is the expected behavior when using API token authentication.

According to the official Kintone documentation, REST API operations performed using API tokens are recorded as operations by Administrator. This explains why the Created by and Updated by fields display Administrator when you add records using your Python code.

You can find this behavior documented here:

However, it is possible to specify a different user for the Created by and Updated by fields when adding records through the REST API, even when using API token authentication.

To do so, you would need to include these fields in your request body and specify the appropriate Kintone user's login name.

For example, you could modify the record portion of your code as follows:

"record": {
    "name": {"value": name},
    "Created_by": {
        "value": {"code": "your_login_name"}
    },
    "Updated_by": {
        "value": {"code": "your_login_name"}
    }
}

Please note the API token must have Add records and Manage App permissions to specify these values.

I have also tested this behavior in a test environment and confirmed that specifying these fields successfully assigns the designated user instead of Administrator.

For more details, please refer to the official Add Record API documentation:

Please also note that the Created by and Updated by fields can only be explicitly specified when adding a record. They cannot be directly modified afterward through the Update Record API.

I hope this helps!

One clarification: your JS customization isn't actually setting Created by or Updated by. It runs as the logged-in user and copies Updated_by into a USER_SELECT field, so the real audit fields still reflect that user. With API token auth, the actor is Administrator by design. If you pass Created_by/Updated_by in the add-record payload, use login names (not display names) and ensure the token has Manage App; otherwise the request can fail. Set these on creation rather than relying on the JS workaround.