Upload First-Party Segments

Prev Next

The First-Party Segment (FPS) API allows you to create a first-party segment easily through an API. After uploading, the segment is automatically created on your First-Party Segment page under Saved Segments. In addition, you can see the results of the segment creation in the callback.

The FPS segments don't generate new users; instead, they group existing users into segments based on their attribute values.

First-Party Segments API vs. Upsert API

  • Use the First-Party Segments API to create a segment from existing users based on one attribute supplied in the request.

  • Use the Upsert API to create new users or update attributes, events, and other data on user profiles.

If users or their profile attributes must first be created or updated, complete that operation through the Upsert API before using the First-Party Segments API.

Use Cases

  • Assume that you want to pass your custom segment(s) via API to Insider One, but do not want to create a segment on Insider One's InOne panel. With the FPS API, you can manage the entire segment creation process from start to finish.

  • Let's say you want to target a set of specific user attributes that contain “Store ID” on UCD. You can create a .csv file, name its first column "Store ID," and include the corresponding store ID values. To make these attribute values produce a segment, you can pass this file’s URL to the payload, and at the end of the request, you can get the number of users with these values.

Store ID

id1

id2

  • Assume that you have 17k store owners as your customers. Instead of multi-selecting 17k values under the segmentation filter, you can list those store_id values on a sheet and upload them to the FPS segment upload field. This way, a snapshot of the people with those Store ID values is generated.

You do not need to include a header row in the CSV file. The attribute name (e.g., "Store ID") has already been specified in the API payload. The values in the CSV file should be listed without a header.

Endpoint and Headers

POST https://contact.useinsider.com/fps/v1/upload

Visit our Postman collection to test this request.

Headers

Header

Sample Value

Description

X-PARTNER-NAME

mybrand

This is your partner name. Navigate to Inone Settings > Account Settings to copy your partner name. The partner name should be lowercase.

X-REQUEST-TOKEN

1a2b3c4e5d6f

This key is required to authorize your request. Refer to API Authentication Tokens to generate your First Party Segment token.

Content-Type

application/json

This header specifies the media type of the resource.

Body Parameters

Parameter

Description

Data Type

Required

segmentName

The name of the segment

String

Yes

fileUrl

The URL where the CSV is hosted. This URL should be downloadable.

String

Yes

callbackUrl

The callback URL is used to receive the result of segment creation. This URL should accept a POST request.

String

Yes

attributeName

The name of the user attribute on which the segment is created. It refers to the attribute names on UCD. This field lets you match users with the specified attribute.
Attribute names should follow the Attribute Name field on the Default Attributes page.
It can be either an identifier or any attribute.

String

Yes

Sample Request

Every request to the request endpoint requires a JSON-formatted body containing the necessary parameters.

The sample below displays a request to upload a customer file (CSV) to create or update an FPS segment.

  • For default attributes, use their display names.

  • For custom attributes, you can use any name without restriction.

curl --location --request POST 'https://contact.useinsider.com/fps/v1/upload' \
--header 'X-REQUEST-TOKEN: acb123' \
--header 'X-PARTNER-NAME: mybrand' \
--header 'Content-Type: application/json' \
--data-raw '{
  "segmentName": "My Segment Name",
  "fileUrl": "https://s3.amazonaws.com/sample_csv_file.csv",
  "callbackUrl": "https://localhost/12345",
  "attributeName": "Email Address"
}'

Sample Responses

202 Accepted

{
  "statusMessage": "Accepted"
}

400 Bad Request

{
  "statusMessage": "segment name already in use"
}

401 Unauthorized

{
  "statusMessage": "Unauthorized"
}

400 Invalid Payload

{
    "error": "Invalid Payload."
}

Sample Callback Responses

200 OK

{
    "segment_name": "My unique segment",
    "valid_values_count": 5,
    "invalid_values_count": 7,
    "total_entered_values": 12
}
  • valid_values_count: The number of valid row values for the given attribute in the body.

  • invalid_values_count: The number of invalid row values for the given attribute in the body. For example, you tried to map the CSV file given below to the age attribute. Since the age attribute is a number, the invalid_values_count will be 2 in this case.

  • total_entered_values: the total number of rows in the .csv file.

Error reference

Use this table to identify and resolve the errors this endpoint returns. Each row shows the status code, the response body you receive, what causes it, and how to fix it.

Status

JSON response

Cause

Fix

202 Accepted

{
  "statusMessage": "Accepted"
}

The request was accepted, and the file was queued for processing. Acceptance means the request itself was well-formed. It does not mean the file was read, validated, or turned into a segment; that happens afterward.

Treat this as the start of the job, not the end. Handle the callback to learn whether the file was actually processed, since a segment that never materializes will otherwise look like a success in your logs. Note that the endpoint page currently publishes the success response as 200 OK with a statusMessage of OK, which needs to be reconciled with this code.

400 Bad Request

{"statusMessage": "segment name already in use"}

A segment with this name already exists on your panel. Segment names must be unique.

Use a different segment name. To replace the contents of an existing segment, delete it in the panel first, or version the name, for example loyalty_tier_a_2026_09.

400 Bad Request

{"statusMessage": "Partner Name is required"}

The X-PARTNER-NAME header is absent from the request.

Add the X-PARTNER-NAME header. Its value must be lowercase and match your panel name exactly. The requirement applies to the value, not to the header name.

400 Bad Request

{
    "error": "Invalid Payload."
}

The request body is not valid JSON, or it does not match the expected structure.

Validate the payload as JSON. Use double quotes for keys and string values, and confirm every required field is present.

401 Unauthorized

{"statusMessage": "Unauthorized"}

The API key in the authorization header is missing, incorrect, or revoked.

Generate a current API key in the panel and send it as the authorization key. See API Authentication Tokens.

429 Too Many Requests

{"statusMessage": "Too Many Requests"}

The request rate exceeded 100 requests per second for the same partner. The limit applies per partner, so every integration sending under the same partner name shares it.

Throttle your client and retry with exponential backoff. Because each upload processes a whole file, a single correctly sized request is almost always preferable to many small ones. To request a higher limit, contact the Insider One team.

400 Callback (asynchronous)

{
  "status_code": 400,
  "message": "the file you are trying to upload has an issue."
}

Sent to your callback URL, not returned by the original request. The file failed background validation for one of two reasons: the URL does not end in a lowercase .csv, or the file exceeds the configured size limit (50 MB by default). The response is deliberately generic and does not say which applies.

Check both conditions. The URL check looks only at whether the final part of the URL ends in a lowercase .csv, so a URL that is otherwise valid still fails if the extension is uppercase or absent. Then confirm the file is under the configured limit, and either reduce the file size or contact the Insider One team to request a higher limit. Because this arrives on the callback, an integration that does not handle the callback will record the upload as successful and never learn the segment was not created.

Limitations

  • All functions must be executed with a simple HTTPS POST request.

  • Provide the API Key as the authorization key in the request header. If the key is incorrect, the operation will not be executed,  and an authorization error will return in the response.

  • The value of the X-PARTNER-NAME header should be lowercase.

  • callbackUrl needs to accept a POST response.

  • You can send up to 100 requests per second with the same API Key. If you exceed the rate limit, you will receive a 429 error.

  • The file size cannot exceed 50 MB.

  • SegmentName can be up to 40 characters.

The default limit shown here is a standard baseline. If your use case requires higher capacity, feel free to reach out to the Insider One team. We can adjust it to fit your needs.