Skip to content

Commit c804f82

Browse files
authored
Feedback edit (#500)
* fix formatting * more formatting sadness
1 parent 53180e6 commit c804f82

File tree

1 file changed

+74
-79
lines changed

1 file changed

+74
-79
lines changed

src/personas/profile-api.md

Lines changed: 74 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,20 @@ This document has four parts…
3333
Your access secret allows you to call the Segment API and access customer data. We do not recommend exposing this key in client applications (see the end of this section for more details).
3434

3535

36-
1. Head over to _Personas > Settings > Access Secrets_: `https://app.segment.com/<your-workspace>/personas/settings` (replace <your-workspace> with your own workspace).
37-
2. Create your **Access Secret** with name, for e.g. `testing/development`
36+
1. Go to _Personas > Settings > Access Secrets_: `https://app.segment.com/<your-workspace>/personas/settings` (replace <your-workspace> with your own workspace).
37+
2. Create your **Access Secret** with name, for e.g. `testing/development`
3838

39-
![](images/1516309197043.png)
39+
![](images/1516309197043.png)
4040

41-
3. Press Generate. Copy the resulting **Access Secret** and store it in a file on your computer as it's only shown once. You'll pass in the **Access Secret** into the Profile API for authorization (via the HTTP basic auth username).
42-
![](images/1526362840437.png)
41+
3. Press Generate. Copy the resulting **Access Secret** and store it in a file on your computer as it's only shown once. You'll pass in the **Access Secret** into the Profile API for authorization (via the HTTP basic auth username).
42+
![](images/1526362840437.png)
4343

44-
4. Profile API request URLs require your space ID. For example:
44+
4. Profile API request URLs require your space ID. For example:
45+
`https://profiles.segment.com/v1/spaces/<your-namespace-id>/collections/users/profiles/<external_id>/events`
4546

46-
https://profiles.segment.com/v1/spaces/<your-namespace-id>/collections/users/profiles/<external_id>/events
47+
Your namespace ID can be found here: [https://app.segment.com/goto-my-workspace/personas/spaces/default/settings/api-access](https://app.segment.com/goto-my-workspace/personas/spaces/default/settings/api-access)
4748

48-
Your namespace ID can be found here: [https://app.segment.com/goto-my-workspace/personas/spaces/default/settings/api-access](https://app.segment.com/goto-my-workspace/personas/spaces/default/settings/api-access)
49-
50-
![](images/space_ID_location.png)
49+
![](images/space_ID_location.png)
5150

5251

5352
**B. Find a user's external id**
@@ -60,26 +59,23 @@ Your namespace ID can be found here: [https://app.segment.com/goto-my-workspace/
6059

6160
**C. Query the user's event history**
6261

63-
1. Download and open [Postman](https://www.getpostman.com/), a nice app for exploring HTTP APIs
64-
2. Create your Postman GET request to query the user's event's history:
65-
i. The URL is:
66-
67-
`https://profiles.segment.com/v1/spaces/<your-namespace-id>/collections/users/profiles/<external_id>/events`
68-
69-
70-
ii. Replace `<your-namespace-id>` with your own namespace id found here:
71-
[https://app.segment.com/goto-my-workspace/personas/spaces/default/settings/api-access](https://app.segment.com/goto-my-workspace/personas/spaces/default/settings/api-access)
62+
1. Download and open [Postman](https://www.getpostman.com/), a nice app for exploring HTTP APIs
63+
2. Create your Postman GET request to query the user's event's history:
64+
i. The URL is:
65+
`https://profiles.segment.com/v1/spaces/<your-namespace-id>/collections/users/profiles/<external_id>/events`
7266

67+
ii. Replace `<your-namespace-id>` with your own namespace id found here:
68+
[https://app.segment.com/goto-my-workspace/personas/spaces/default/settings/api-access](https://app.segment.com/goto-my-workspace/personas/spaces/default/settings/api-access)
7369

74-
iii. Replace `<id_type:ext_id>` with your external id type and id pair from step B
7570

71+
iii. Replace `<id_type:ext_id>` with your external id type and id pair from step B
7672

77-
iv. Copy your **Access Secret** from step (A) into the _Basic Auth > Username field_. Leave Password empty.
73+
iv. Copy your **Access Secret** from step (A) into the _Basic Auth > Username field_. Leave Password empty.
7874

7975

80-
![](images/postman_basic_auth.png)
76+
![](images/postman_basic_auth.png)
8177

82-
3. Press the Send button in Postman.
78+
3. Press the Send button in Postman.
8379

8480
**D. Explore the user's event history in the response**
8581

@@ -91,7 +87,6 @@ Your namespace ID can be found here: [https://app.segment.com/goto-my-workspace/
9187
**Search by an External ID**
9288
You can query directly by a user's email or user_id:
9389

94-
9590
`https://profiles.segment.com/v1/spaces/<your-namespace-id>/collections/users/profiles/email:[email protected]/events`
9691

9792

@@ -139,7 +134,6 @@ curl https://profiles.segment.com/v1/spaces/<your-namespace-id>/collections/user
139134

140135

141136
## API Reference
142-
### Introduction
143137

144138
The Segment API is organized around [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer). Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in 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.
145139

@@ -184,12 +178,12 @@ Segment uses conventional HTTP response codes to indicate the success or failur
184178
**Error Body**
185179

186180
```js
187-
{
188-
"error": {
189-
"code": "validation_error",
190-
"message": "The parameter `collection` has invalid character(s) `!`"
191-
}
192-
}
181+
{
182+
"error": {
183+
"code": "validation_error",
184+
"message": "The parameter `collection` has invalid character(s) `!`"
185+
}
186+
}
193187
```
194188

195189
| **Code** | **Message** |
@@ -236,6 +230,7 @@ Request-Id: 1111-2222-3333-4444
236230
```
237231

238232
### Routes
233+
239234
| **Name** | **Route** https://profiles.segment.com/v1/spaces/:space_id:/ ... |
240235
| ---------------------------- | -------------------------------------------------------------------- |
241236
| Get a Profile's Traits | collections/users/profiles/email:amir@segment.com/traits |
@@ -276,53 +271,53 @@ GET /v1/spaces/lg8283283/collections/users/profiles/user_id:u1234/traits
276271
**404 Not Found**
277272

278273
```js
279-
{
280-
"error": {
281-
"code": "not_found",
282-
"message": "Profile was not found."
283-
}
284-
}
274+
{
275+
"error": {
276+
"code": "not_found",
277+
"message": "Profile was not found."
278+
}
279+
}
285280
```
286281

287282
**200 OK**
288283

289284
```js
290-
{
291-
"traits": {
292-
"first_name": "Bob",
293-
"emails_opened_last_30_days": 33,
294-
},
295-
"cursor": {
296-
"url": "/v1/spaces/lgJ4AAjFN4/collections/users/profiles/use_RkjG0kW53igMijEISMH0vKBF4sL/traits",
297-
"has_more": false,
298-
"next": ""
299-
}
300-
}
285+
{
286+
"traits": {
287+
"first_name": "Bob",
288+
"emails_opened_last_30_days": 33,
289+
},
290+
"cursor": {
291+
"url": "/v1/spaces/lgJ4AAjFN4/collections/users/profiles/use_RkjG0kW53igMijEISMH0vKBF4sL/traits",
292+
"has_more": false,
293+
"next": ""
294+
}
295+
}
301296

302297
```
303298

304299
And when ?**verbose=true** mode on:
305300

306301
```js
307-
{
308-
"traits": {
309-
"first_name": {
310-
"value": "Bob",
311-
"source_id": "..",
312-
"updated_at": ".."
313-
}
314-
"emails_opened_last_30_days": {
315-
"value": 33,
316-
"source_id": "..",
317-
"updated_at": ".."
318-
}
319-
},
320-
"cursor": {
321-
"url": "/v1/spaces/lgJ4AAjFN4/collections/users/profiles/use_RkjG0kW53igMijEISMH0vKBF4sL/traits",
322-
"has_more": false,
323-
"next": ""
324-
}
302+
{
303+
"traits": {
304+
"first_name": {
305+
"value": "Bob",
306+
"source_id": "..",
307+
"updated_at": ".."
308+
}
309+
"emails_opened_last_30_days": {
310+
"value": 33,
311+
"source_id": "..",
312+
"updated_at": ".."
325313
}
314+
},
315+
"cursor": {
316+
"url": "/v1/spaces/lgJ4AAjFN4/collections/users/profiles/use_RkjG0kW53igMijEISMH0vKBF4sL/traits",
317+
"has_more": false,
318+
"next": ""
319+
}
320+
}
326321
```
327322

328323
**Query Parameters**
@@ -354,12 +349,12 @@ curl https://profiles.segment.com/v1/spaces/:namespace_id:/collections/users/pro
354349
**404 Not Found**
355350

356351
```js
357-
{
358-
"error": {
359-
"code": "not_found",
360-
"message": "Profile was not found."
361-
}
362-
}
352+
{
353+
"error": {
354+
"code": "not_found",
355+
"message": "Profile was not found."
356+
}
357+
}
363358
```
364359

365360
**200 OK**
@@ -627,13 +622,13 @@ Since this API has access to all of a customer's data, we do not support CORS an
627622
If you want to display the most relevant blog posts given a reader's favorite blog category:
628623

629624

630-
1. **Create a computed trait** `favorite_blog_category` **in Segment UI** [Marketer or Engineer]
631-
2. **Create** `/api/recommended-posts` **in customer-built personalization service** [Engineer]
632-
- Accept `user_id`, `email` or `anonymous_id` to fetch `favorite_blog_category` via API
633-
- Return array of most recent posts of that category to render in recommended section
634-
3. **Add recommended section to the blog** [Engineer]
635-
- Client-side by making a request to `/recommended-posts` if it accepts CORS (recommended for static blogs, WordPress plugin, or other CMS solutions)
636-
- Server-side by collecting all the personalizations you want to make on the blog in a single request to increase the total time to load (recommended for custom blog setup)
625+
1. **Create a computed trait** `favorite_blog_category` **in Segment UI** [Marketer or Engineer]
626+
2. **Create** `/api/recommended-posts` **in customer-built personalization service** [Engineer]
627+
- Accept `user_id`, `email` or `anonymous_id` to fetch `favorite_blog_category` via API
628+
- Return array of most recent posts of that category to render in recommended section
629+
3. **Add recommended section to the blog** [Engineer]
630+
- Client-side by making a request to `/recommended-posts` if it accepts CORS (recommended for static blogs, WordPress plugin, or other CMS solutions)
631+
- Server-side by collecting all the personalizations you want to make on the blog in a single request to increase the total time to load (recommended for custom blog setup)
637632

638633
Now, users who take a few minutes to read through an article on the blog will find posts recommended using their historical reading pattern including the post they just read.
639634

0 commit comments

Comments
 (0)