Upload First-Party Segments
  • 06 Dec 2023
  • 3 Minutes to read

    Upload First-Party Segments


      Article Summary

      Overview

      The First-Party Segment API allows you to easily create a first-party segment through an API. When the uploading process is completed, 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 on the callback.

      Use Cases

      • Assume that you want to pass your custom segment(s) via API to Insider but you do not want to create a segment on Insider's InOne panel. Thanks to FPS API, you can maintain all of the segment creation process through the API from beginning to the end.
      • Let's say you want to target a set of specific user attributes that contain “Store ID” on UCD. You can basically create a .csv file and name its column as Store ID with the 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 who have 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 it on the FPS segment upload field. This way, a snapshot of the people having those store id values are generated.

      Endpoint and Headers

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

      Headers

      HeaderSample ValueDescription
      X-PARTNER-NAMEmybrandThis is your partner name. Navigate to InOne > InOne Settings > Account Preferences to copy your partner name. The partner name should be lowercase.
      X-REQUEST-TOKEN1a2b3c4e5d6fThis key is required to authorize your request. Refer to API Authentication Tokens to generate your First Party Segment token.
      Content-Typeapplication/jsonThis header specifies the media type of the resource.

      Body Parameters

      ParameterDescriptionData TypeRequired
      segmentNameIt is the name of the segment.StringYes
      fileUrlIt is the URL where CSV is hosted. This URL should be downloadable.StringYes
      callbackUrlCallback URL is to receive the result of segment creation. This URL should accept POST request.StringYes
      attributeNameIt is the name of the user attribute on which the segment is created. It refers to the attribute names on UCD. This field basically enables you to match your users who have the given attribute.
      Attribute names should be in accordance with Attribute Name field on Default Attributes page.
      It can be either an identifier or any attribute.
      StringYes

      Sample Example

      Sample Request

      Every request made to the request endpoint requires a request body formatted in JSON containing the required body parameters.

      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"
      }'
      Your title goes here
      You need to write display names for default attributes, such as Email Address for em. However, there is no such restriction for custom attributes.

      Sample Responses

      200 OK

      {
        "statusMessage": "OK"
      }

      400 Bad Request

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

      401 Unauthorized

      {
        "statusMessage": "Unauthorized"
      }

      405 Invalid Payload

      {
          "error": "Invalid Payload."
      }

      Error Messages

      ErrorDescription
      segment name already in useThe segment name in the request already exists on your panel. You should name your segment with a different name.
      the file URL is invalid. The URL should include .csv extensionThe CSV URL is invalid. The URL should include .csv extension.
      file size is more than the limitFile size cannot be more than 10MB.
      partner name is missingX-PARTNER-NAME needs to be available.

      Sample Callback Responses

      200 OK

      {
          "status": 200,
          "segment_name": "My unique segment",
          "value_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 with the age attribute. Since 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.

      Limitations

      • All functions must be executed with a simple HTTPS POST request.
      • The API Key should be provided as the authorization key on 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 POST response
      • File size cannot be more than 50MB.

      Was this article helpful?

      ESC

      Eddy, a super-smart generative AI, opening up ways to have tailored queries and responses