User Attribute Upload API
The Ptengine API allows you to bulk upload user attribute data to Ptengine for use in user segmentation analysis and other features.
The API is built on REST architecture, accepts JSON-formatted request bodies, and returns JSON-encoded responses.
1. Authentication
Obtaining an API Key
Obtain or create a new API key from the "Integration" page in Ptengine.
API keys are issued at the project level. Each project requires its own API key.
Protecting Your API Key
API keys are confidential. Do not expose them in client-side code such as browsers or mobile apps. Route production requests through your backend server and load keys securely from environment variables or a key management service.
All API requests must include the API key in the HTTP header:
Authorization: Bearer PTENGINE_API_KEY2. API Specification
API URL
https://api.ptengine.com/v1/user/profiles
Protocol
HTTPS
Method
POST
Data Format
JSON
A single request can upload up to 100 users with their attribute data.
3. Request Body
The request body contains two fields:
field_name
String[]
Yes
Array of attribute key names. Must include user_id
Maximum 50 fields, each name up to 50 characters
values
Array[]
Yes
Two-dimensional array of user attribute values. The order must correspond to field_name. Use "" for empty values
Maximum 100 users, each value up to 128 characters
4. Update Policy
Each request must include user_id (a unique user identifier). Ptengine uses user_id to check whether the user already exists and processes accordingly:
Exists
Exists
Updates the existing attributes
Exists
Does not exist
Creates new attributes for the user
Does not exist
/
Creates a new user and their attributes
5. Request Example
Suppose you want to upload the following user attributes:
abcd123
yes
no
abcd456
yes
yes
abcd789
no
no
The request body would be:
6. Code Examples
Replace <API_KEY> with your actual API key before sending requests.
Python
Node.js
PHP
Java
Go
7. Response
Success
HTTP status code 200 OK
Failure
HTTP status code varies by error type.
Status Code Reference
200 (OK)
Request was successful
400 (Bad Request)
Request could not be accepted. Likely missing required parameters (e.g., field_name does not include user_id)
401 (Unauthorized)
API key is invalid or incorrect
403 (Forbidden)
API key does not have the appropriate permissions for this request
404 (Not Found)
The requested resource does not exist or the URL is incorrect
500/502/503/504
An issue occurred on the Ptengine server
8. Uploading Large Datasets
A single request can upload a maximum of 100 users. If you have more than 100 users, split the data into batches of 100 and send multiple requests.
For example, to upload data for 600 users, split it into 6 requests of 100 users each.
最終更新