Skip to content

Commit 585cde2

Browse files
committed
Profile API Updates
1 parent 7757835 commit 585cde2

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

src/personas/profile-api.md

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ The Segment Profile API provides a single API to read user-level and account-lev
1212

1313
You can use this API to:
1414

15-
- **Build an in-app recommendation** engine to show users or accounts the last 5 products they viewed but didn't purchase
15+
- **Build an in-app recommendation** engine to show users or accounts the last five products they viewed but didn't purchase
1616
- **Empower your sales and support associates** with the complete customer context by embedding the user profile in third-party tools like Zendesk or Desk.com
1717
- **Power personalized marketing campaigns** by enriching dynamic / custom properties with profile traits in marketing tools like Braze
1818
- **Qualify leads faster** by embedding the user event timeline in Salesforce
1919

20-
This document has four parts
20+
This document has four parts:
2121

2222
1. [**Product Highlights**](#product-highlights)
2323
2. [**Quickstart**](#quickstart): Walks you through how to get started querying your user profile in <1 min
2424
3. [**API Reference**](#api-reference): Retrieve a list of users sorted by recent activity or find a particular user
2525
4. [**Best Practices**](#recommended-implementation): Recommended implementation and example Profile API workflow
2626

27-
## Product Highlights
27+
## Product highlights
2828
1. **Fast response times** — fetch traits from a user profile under 200ms
2929
2. **Real-time data** — query streaming data on the user profile
3030
3. **One identity** — query an end user's interactions across web, mobile, server, and third party touch-points
@@ -36,7 +36,7 @@ This document has four parts…
3636
> warning ""
3737
> **Important**: The Profile API is intended to be used server-side. You should not implement directly in client applications. See the [Best Practices](#recommended-implementation) section for more details.
3838
39-
### Configure Access
39+
### Configure access
4040

4141
Your access token enables you to call the Profile API and access customer data.
4242

@@ -59,6 +59,10 @@ Your access token enables you to call the Profile API and access customer data.
5959
2. Take note of the user's available identifiers. For example, this user has a `user_id` with the value `9800664881`. The Profile API requires both the type of ID and the value separated by a colon. For example, `user_id:9800664881`.
6060
![Retrieving a user's identifiers with the Personas Explorer](images/profile_api_user_id.png)
6161

62+
> warning ""
63+
> To query phone numbers that contain a plus sign (`+`), insert the escape characters `%2B` in place of the plus sign. <br>
64+
> For example, if a `phone_number` identifier has the value `+5555550123`, enter `phone_number:%2B5555550123` in your query.
65+
6266
### Query the user's event traits
6367

6468
1. From the HTTP API testing application of your choice, configure the authentication as described above.
@@ -122,16 +126,18 @@ You can query all of a user's metadata (created_at, updated_at, ...):
122126

123127
**Search an account profile**
124128

125-
If you are sending group calls to Segment, you can now access your account profiles as well. You can retrieve your account traits, computed traits, and audience traits by querying the `group_id` you are interested in:
129+
If you're sending group calls to Segment, you can now access your account profiles as well. Retrieve your account traits, computed traits, and audience traits by querying the `group_id` you are interested in:
126130

127131
`https://profiles.segment.com/v1/spaces/<your-namespace-id>/collections/accounts/profiles/group_id:12345/traits`
128132

129133
**Search for linked users or accounts**
130134

131-
If you are looking to find all the users linked to an account, you can search for an account's linked users, or a user's linked accounts.
135+
If you're looking to find all the users linked to an account, you can search for an account's linked users, or a user's linked accounts.
132136

133137
`https://profiles.segment.com/v1/spaces/<your-namespace-id>/collections/accounts/profiles/group_id:12345/links`
134138

139+
The return limit for the `/links` endpoint is 20 records. You can request up to 20 records by appending `?limit=20` to the query string.
140+
135141
### cURL
136142

137143
You can also request using cURL:
@@ -144,7 +150,7 @@ curl https://profiles.segment.com/v1/spaces/<your-space-id>/collections/users/pr
144150

145151
## API reference
146152

147-
The Segment API is organized around [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer). The API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. Segment uses standard HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. [JSON](http://www.json.org/) is returned by all API responses, including errors.
153+
The Segment API is organized around [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer){:target="_blank"}. The API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. Segment uses standard HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. [JSON](http://www.json.org/){:target="_blank"} is returned by all API responses, including errors.
148154

149155
**Endpoint**
150156

@@ -157,7 +163,7 @@ The Segment API is organized around [REST](http://en.wikipedia.org/wiki/Represen
157163

158164
### Authentication
159165

160-
The Profile API uses basic authentication for authorization — with the **Access Token** as the authorization key. Your **Access Token** carries access to all of your customer data, so be sure to keep them secret. Do not share your Access Token in publicly accessible areas such as GitHub or client-side code.
166+
The Profile API uses basic authentication for authorization — with the **Access Token** as the authorization key. Your **Access Token** carries access to all of your customer data, so be sure to keep them secret. Don't share your Access Token in publicly accessible areas such as GitHub or client-side code.
161167

162168
You can create your Access Secret in your Personas Settings page. Segment recommends that you name your tokens with the name of your app and its environment, such as `marketing_site/production`. Access tokens are shown once — you won't be able to see it again. In the event of a security incident, you can revoke and cycle the access token.
163169

@@ -205,7 +211,7 @@ Segment uses conventional HTTP response codes to indicate the success or failure
205211
| **rate_limit_error** | Too many requests hit the API too quickly. |
206212
| **validation_error** | Errors triggered when failing to validate fields (for example, when a collection name has invalid characters). |
207213

208-
### Rate Limit
214+
### Rate limit
209215

210216
To ensure low response times, every Space has a default rate limit of 100 requests/sec. Please contact [[email protected]](mailto:[email protected]) if you need a higher limit with details around your use case. For more information about rate limits, see the [Product Limits](/docs/personas/product-limits) documentation.
211217

@@ -269,7 +275,7 @@ Retrieve a single profile's traits within a collection using an `external_id`. F
269275
GET /v1/spaces/<space_id>/collections/<users>/profiles/<external_id>/traits
270276
```
271277

272-
##### Query Parameters
278+
##### Query parameters
273279

274280
| **Argument** | **Description** | **Example** |
275281
| ------------ | -------------------------------------------------------- | ------------------------------------------ |
@@ -401,7 +407,7 @@ curl https://profiles.segment.com/v1/spaces/:space_id:/collections/users/profile
401407
}
402408
```
403409

404-
##### Query Parameters
410+
##### Query parameters
405411

406412
| **Argument** | **Description** | **Example** |
407413
| ------------ | ------------------------------------------------------ | ------------------------- |
@@ -411,7 +417,7 @@ curl https://profiles.segment.com/v1/spaces/:space_id:/collections/users/profile
411417

412418

413419

414-
#### Get a Profile's Events
420+
#### Get a profile's events
415421

416422
Get up to 14 days of a profile's historical events within a collection using an `external_id`.
417423

@@ -505,18 +511,18 @@ Get up to 14 days of a profile's historical events within a collection using an
505511
}
506512
```
507513

508-
##### Query Parameters
514+
##### Query parameters
509515

510516
| **Argument** | **Description** | **Example** |
511517
| ------------ | --------------------------------------------------------------------------------- | --------------------------------- |
512518
| `end` | Returns all the events that end before `end` (in ISO 8601). | `2018-01-02` |
513-
| `exclude` | A comma-separated list of event keys to excluse. | `Page Viewed`,`Experiment Viewed` |
519+
| `exclude` | A comma-separated list of event keys to exclude. | `Page Viewed`,`Experiment Viewed` |
514520
| `include` | A comma-separated list of event keys to include. | `Page Viewed`,`Experiment Viewed` |
515-
| `limit` | Defines how many events are returned in one call | `100` |
521+
| `limit` | Defines how many events are returned in one call. | `100` |
516522
| `sort` | Determines whether the result is ascending or descending. Defaults to descending. | `asc`,`desc` |
517523
| `start` | Returns all the events that start after `start` (in ISO 8601). | `2006-01-02` |
518524

519-
#### Get a Profile's Metadata
525+
#### Get a profile's metadata
520526

521527
Get a single profile's metadata within a collection using an `external_id`.
522528

@@ -559,14 +565,14 @@ Get a single profile's metadata within a collection using an `external_id`.
559565
}
560566
```
561567

562-
##### Query Parameters
568+
##### Query parameters
563569

564570
| **Argument** | **Description** | **Example** |
565571
| ------------ | -------------------------------- | -------------- |
566572
| `verbose` | True for verbose field selection | `true`,`false` |
567573

568574

569-
#### Get a Profile's Linked Users or Accounts
575+
#### Get a profile's linked users or accounts
570576

571577
Get the users linked to an account, or accounts linked to a user, using an `external_id`.
572578

@@ -626,14 +632,14 @@ GET /v1/spaces/<space_id>/collections/<users>/profiles/<external_id>/links
626632
}
627633
```
628634

629-
## Best Practices
630-
### Recommended Implementation
635+
## Best practices
636+
### Recommended implementation
631637

632-
The Profile API does not support CORS because it has access to the sum of a customer's data. Segment also requests that you prevent the Access Token to the public, for example in a client-side application. Engineers implementing this API are advised to create a personalization service in their infrastructure, which other apps, websites, and services communicate with to fetch personalizations about their users.
638+
The Profile API doesn't support CORS because it has access to the sum of a customer's data. Segment also requests that you prevent the Access Token to the public, for example in a client-side application. Engineers implementing this API are advised to create a personalization service in their infrastructure, which other apps, websites, and services communicate with to fetch personalizations about their users.
633639

634640
![Server-side Personalization](https://www.lucidchart.com/publicSegments/view/25df2e70-a666-4581-8f86-1a000dbf1f49/image.png)
635641

636-
### Example Workflow
642+
### Example workflow
637643

638644
If you want to display the most relevant blog posts given a reader's favorite blog category:
639645

@@ -653,7 +659,7 @@ Segment does not recommend using `external_ids` as a lookup field that might con
653659

654660
### Performance
655661

656-
Segment typically sees p95 response times under 200ms for the `/traits` endpoint, based on an in-region test in `us-west` to retrieve 50 traits. However, if you know which traits you are looking for, Segment suggests you use the `/traits?include=` parameter to provide a list of traits want to retrieve.
662+
Segment typically sees p95 response times under 200ms for the `/traits` endpoint, based on an in-region test in `us-west` to retrieve 50 traits. However, if you know which traits you're looking for, Segment suggests you use the `/traits?include=` parameter to provide a list of traits you want to retrieve.
657663

658664
Another best practice to optimize performance in high-throughput applications is to use connection pooling. Your personalization service should share existing connections when making a request to the Profile API, instead of opening and closing a connection for each request. This additional TLS handshake is a common source of overhead for each request.
659665

0 commit comments

Comments
 (0)