{ "info": { "_postman_id": "d9427670-bacd-4557-83d2-8f56a70c3b8c", "name": "Optimizely Full Stack API", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Projects", "item": [ { "name": "Create Full Stack Project", "event": [ { "listen": "test", "script": { "id": "d8e8a2bf-39c9-489c-9934-51efd4dd6a3b", "type": "text/javascript", "exec": [ "let response = pm.response.json()", "pm.environment.set(\"project_id\", response.id)", "pm.environment.set(\"account_id\", response.account_id)", "", "pm.test(\"response is created\", function () {", " pm.response.to.have.status(201);", "});" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"name\": \"Full Stack Test Project\",\n \"platform\": \"custom\"\n}" }, "url": { "raw": "{{host}}/v2/projects", "host": [ "{{host}}" ], "path": [ "v2", "projects" ] } }, "response": [] }, { "name": "Get Project by ID", "event": [ { "listen": "prerequest", "script": { "id": "7f337f5a-7ec5-4704-a297-d20e3a857c9c", "type": "text/javascript", "exec": [ "" ] } }, { "listen": "test", "script": { "id": "38fb0771-cf7b-4606-9b75-7f419cc49770", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/projects/{{project_id}}", "host": [ "{{host}}" ], "path": [ "v2", "projects", "{{project_id}}" ] } }, "response": [] }, { "name": "List Projects", "event": [ { "listen": "test", "script": { "id": "d451da10-32fb-4698-85d4-5e1d456e0e21", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/projects", "host": [ "{{host}}" ], "path": [ "v2", "projects" ] } }, "response": [] }, { "name": "Update Project", "event": [ { "listen": "test", "script": { "id": "fa52cc4d-d894-46d3-9a74-0796e3953689", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"confidence_threshold was updated\", function () {", " let response = pm.response.json()", " pm.expect(response.confidence_threshold).to.equal(0.95)", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"confidence_threshold\": 0.95\n}" }, "url": { "raw": "{{host}}/v2/projects/{{project_id}}", "host": [ "{{host}}" ], "path": [ "v2", "projects", "{{project_id}}" ] } }, "response": [] }, { "name": "Archive Project", "event": [ { "listen": "test", "script": { "id": "ac153334-e6fd-4c2c-a659-9cf8f0bcc1ff", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"status is archived\", function () {", " let response = pm.response.json()", " pm.expect(response.status).to.equal('archived')", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"status\": \"archived\"\n}" }, "url": { "raw": "{{host}}/v2/projects/{{project_id}}", "host": [ "{{host}}" ], "path": [ "v2", "projects", "{{project_id}}" ] } }, "response": [] }, { "name": "Unarchive Project", "event": [ { "listen": "test", "script": { "id": "b94b6466-5a87-4c01-8f79-2f68e198b464", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"status is archived\", function () {", " let response = pm.response.json()", " pm.expect(response.status).to.equal('active')", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"status\": \"active\"\n}" }, "url": { "raw": "{{host}}/v2/projects/{{project_id}}", "host": [ "{{host}}" ], "path": [ "v2", "projects", "{{project_id}}" ] } }, "response": [] } ], "protocolProfileBehavior": {} }, { "name": "Attributes", "item": [ { "name": "Create Attribute", "event": [ { "listen": "test", "script": { "id": "bf528a39-bb89-411b-be56-850eb3d39ad2", "type": "text/javascript", "exec": [ "let response = pm.response.json()", "pm.environment.set(\"attribute_id\", response.id)", "pm.environment.set(\"attribute_key\", response.key)", "", "pm.test(\"response is created\", function () {", " pm.response.to.have.status(201);", "});" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"project_id\": {{project_id}},\n \"key\": \"is_power_user_{{$timestamp}}\"\n}" }, "url": { "raw": "{{host}}/v2/attributes", "host": [ "{{host}}" ], "path": [ "v2", "attributes" ] } }, "response": [] }, { "name": "Get Attribute by ID", "event": [ { "listen": "prerequest", "script": { "id": "7f337f5a-7ec5-4704-a297-d20e3a857c9c", "type": "text/javascript", "exec": [ "" ] } }, { "listen": "test", "script": { "id": "5b848094-5392-4c02-b205-314e1b4b6299", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/attributes/{{attribute_id}}", "host": [ "{{host}}" ], "path": [ "v2", "attributes", "{{attribute_id}}" ] } }, "response": [] }, { "name": "List Attributes", "event": [ { "listen": "test", "script": { "id": "1b655897-b0c3-4112-b1f8-a24f75c41f6c", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/attributes?project_id={{project_id}}", "host": [ "{{host}}" ], "path": [ "v2", "attributes" ], "query": [ { "key": "project_id", "value": "{{project_id}}" } ] } }, "response": [] }, { "name": "Update Attribute", "event": [ { "listen": "test", "script": { "id": "3c534564-b113-4c17-ac5f-da3b2d4b11d9", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"description was updated\", function () {", " let response = pm.response.json()", " pm.expect(response.description).to.equal('Updated attribute description')", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"description\": \"Updated attribute description\"\n}" }, "url": { "raw": "{{host}}/v2/attributes/{{attribute_id}}", "host": [ "{{host}}" ], "path": [ "v2", "attributes", "{{attribute_id}}" ] } }, "response": [] }, { "name": "Archive Attribute", "event": [ { "listen": "test", "script": { "id": "5bc4ce80-b751-41a7-8842-46af64a95ca1", "type": "text/javascript", "exec": [ "pm.test(\"response is no content\", function () {", " pm.response.to.have.status(204);", "});" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{host}}/v2/attributes/{{attribute_id}}", "host": [ "{{host}}" ], "path": [ "v2", "attributes", "{{attribute_id}}" ] } }, "response": [] }, { "name": "Unarchive Attribute", "event": [ { "listen": "test", "script": { "id": "cbc58597-3c80-45a5-be5c-0514daac82c0", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"archived is false\", function () {", " let response = pm.response.json()", " pm.expect(response.archived).to.equal(false)", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"archived\": false\n}" }, "url": { "raw": "{{host}}/v2/attributes/{{attribute_id}}", "host": [ "{{host}}" ], "path": [ "v2", "attributes", "{{attribute_id}}" ] } }, "response": [] } ], "protocolProfileBehavior": {} }, { "name": "Audiences", "item": [ { "name": "Create Audience", "event": [ { "listen": "test", "script": { "id": "13250ff1-4b0f-43b3-bde8-20a9bfba4138", "type": "text/javascript", "exec": [ "let response = pm.response.json()", "pm.environment.set(\"audience_id\", response.id)", "", "pm.test(\"response is created\", function () {", " pm.response.to.have.status(201);", "});" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"project_id\": {{project_id}},\n \"name\": \"Power Users {{$timestamp}}\",\n \"conditions\": \"[\\\"and\\\",[\\\"or\\\",[\\\"or\\\",{\\\"name\\\":\\\"{{attribute_key}}\\\", \\\"value\\\":\\\"true\\\", \\\"type\\\":\\\"custom_attribute\\\"}]]]\"\n}" }, "url": { "raw": "{{host}}/v2/audiences", "host": [ "{{host}}" ], "path": [ "v2", "audiences" ] } }, "response": [] }, { "name": "Get Audience by ID", "event": [ { "listen": "prerequest", "script": { "id": "7f337f5a-7ec5-4704-a297-d20e3a857c9c", "type": "text/javascript", "exec": [ "" ] } }, { "listen": "test", "script": { "id": "ae377be9-1d61-4b84-acd9-1ba12e5390f9", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/audiences/{{audience_id}}", "host": [ "{{host}}" ], "path": [ "v2", "audiences", "{{audience_id}}" ] } }, "response": [] }, { "name": "List Audiences", "event": [ { "listen": "test", "script": { "id": "f0db1070-eb34-411a-9d91-9d3dd2ea63be", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/audiences?project_id={{project_id}}", "host": [ "{{host}}" ], "path": [ "v2", "audiences" ], "query": [ { "key": "project_id", "value": "{{project_id}}" } ] } }, "response": [] }, { "name": "Update Audience", "event": [ { "listen": "test", "script": { "id": "5780b594-8261-4018-b865-cb2937acd638", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"name was updated\", function () {", " let response = pm.response.json()", " pm.expect(response.name).to.equal('Probable Power Users')", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"description\": \"Updated audience description\",\n\t\"name\": \"Probable Power Users\",\n\t\"conditions\": \"[\\\"and\\\",[\\\"or\\\",[\\\"or\\\",{\\\"name\\\":\\\"{{attribute_key}}\\\", \\\"value\\\":\\\"probably\\\", \\\"type\\\":\\\"custom_attribute\\\"}]]]\"\n}" }, "url": { "raw": "{{host}}/v2/audiences/{{audience_id}}", "host": [ "{{host}}" ], "path": [ "v2", "audiences", "{{audience_id}}" ] } }, "response": [] }, { "name": "Archive Audience", "event": [ { "listen": "test", "script": { "id": "ab10641d-8616-4204-a460-df388cd14fbc", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"archived is true\", function () {", " let response = pm.response.json()", " pm.expect(response.archived).to.equal(true)", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"archived\": true\n}" }, "url": { "raw": "{{host}}/v2/audiences/{{audience_id}}", "host": [ "{{host}}" ], "path": [ "v2", "audiences", "{{audience_id}}" ] } }, "response": [] }, { "name": "Unarchive Audience", "event": [ { "listen": "test", "script": { "id": "f58eeaa2-8445-473f-84e7-052f440d37de", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"archived is false\", function () {", " let response = pm.response.json()", " pm.expect(response.archived).to.equal(false)", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"archived\": false\n}" }, "url": { "raw": "{{host}}/v2/audiences/{{audience_id}}", "host": [ "{{host}}" ], "path": [ "v2", "audiences", "{{audience_id}}" ] } }, "response": [] } ], "protocolProfileBehavior": {} }, { "name": "Events", "item": [ { "name": "Create Event", "event": [ { "listen": "test", "script": { "id": "f09e56e6-1fb8-4ae7-aaba-fe0020f14b4a", "type": "text/javascript", "exec": [ "let response = pm.response.json()", "pm.environment.set(\"event_id\", response.id)", "pm.environment.set(\"event_key\", response.key)", "", "pm.test(\"response is created\", function () {", " pm.response.to.have.status(201);", "});" ] } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"key\": \"purchase_{{$timestamp}}\",\n \"name\": \"purchase_{{$timestamp}}\",\n \"description\": \"Indicates a purchase occurred\"\n}" }, "url": { "raw": "{{host}}/v2/projects/{{project_id}}/custom_events", "host": [ "{{host}}" ], "path": [ "v2", "projects", "{{project_id}}", "custom_events" ] } }, "response": [] }, { "name": "Get Event by ID", "event": [ { "listen": "prerequest", "script": { "id": "7f337f5a-7ec5-4704-a297-d20e3a857c9c", "type": "text/javascript", "exec": [ "" ] } }, { "listen": "test", "script": { "id": "5622294f-87f3-4f0f-bcf7-9b7580d57900", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/events/{{event_id}}", "host": [ "{{host}}" ], "path": [ "v2", "events", "{{event_id}}" ] } }, "response": [] }, { "name": "List Events", "event": [ { "listen": "test", "script": { "id": "eb4ece08-1894-466d-8a70-84ed5793118a", "type": "text/javascript", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/events?project_id={{project_id}}", "host": [ "{{host}}" ], "path": [ "v2", "events" ], "query": [ { "key": "project_id", "value": "{{project_id}}" } ] } }, "response": [] }, { "name": "Update Event", "event": [ { "listen": "test", "script": { "id": "f55a8750-858a-4042-ad00-29a374c3c704", "type": "text/javascript", "exec": [ "let response = pm.response.json()", "", "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"key was updated\", function () {", " pm.expect(response.key).to.match(/^purchase_/)", "});", "", "pm.test(\"description was updated\", function () {", " pm.expect(response.description).to.equal('Updated event description')", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"key\": \"purchase_{{$timestamp}}\",\n\t\"description\": \"Updated event description\"\n}" }, "url": { "raw": "{{host}}/v2/projects/{{project_id}}/custom_events/{{event_id}}", "host": [ "{{host}}" ], "path": [ "v2", "projects", "{{project_id}}", "custom_events", "{{event_id}}" ] } }, "response": [] }, { "name": "Archive Event", "event": [ { "listen": "test", "script": { "id": "61b1e00f-2c73-49a8-8e2b-7b6651ffeb50", "type": "text/javascript", "exec": [ "pm.test(\"response is no content\", function () {", " pm.response.to.have.status(204);", "});" ] } } ], "request": { "method": "DELETE", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "" }, "url": { "raw": "{{host}}/v2/projects/{{project_id}}/custom_events/{{event_id}}", "host": [ "{{host}}" ], "path": [ "v2", "projects", "{{project_id}}", "custom_events", "{{event_id}}" ] } }, "response": [] }, { "name": "Unarchive Event", "event": [ { "listen": "test", "script": { "id": "0d00bf56-ff04-48e2-b446-c7c542109e86", "type": "text/javascript", "exec": [ "let response = pm.response.json()", "", "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"archived is false\", function () {", " pm.expect(response.archived).to.equal(false)", "});" ] } } ], "request": { "method": "PATCH", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n\t\"archived\": false\n}" }, "url": { "raw": "{{host}}/v2/projects/{{project_id}}/custom_events/{{event_id}}", "host": [ "{{host}}" ], "path": [ "v2", "projects", "{{project_id}}", "custom_events", "{{event_id}}" ] } }, "response": [] } ], "protocolProfileBehavior": {} }, { "name": "Environments", "item": [ { "name": "Create Environment", "event": [ { "listen": "test", "script": { "id": "12326d3b-292e-4904-9b03-19f45142eeef", "exec": [ "let response = pm.response.json()", "pm.environment.set(\"staging_environment_id\", response.id)", "pm.environment.set(\"staging_environment_key\", response.key)", "", "pm.test(\"response is created\", function () {", " pm.response.to.have.status(201);", "});", "", "pm.test(\"datafile is set\", function () {", " pm.expect(response.datafile.url).to.match(new RegExp('^https://.*/datafiles/' + response.datafile.sdk_key + '.json'))", "});" ], "type": "text/javascript" } } ], "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"project_id\": {{project_id}},\n \"name\": \"Test Environment {{$timestamp}}\",\n \"key\": \"test_environment_{{$timestamp}}\",\n \"description\": \"Test Environment created at {{$timestamp}}\",\n \"has_restricted_permissions\": false\n}" }, "url": { "raw": "{{host}}/v2/environments", "host": [ "{{host}}" ], "path": [ "v2", "environments" ] } }, "response": [] }, { "name": "Get Environment by ID", "event": [ { "listen": "prerequest", "script": { "id": "7f337f5a-7ec5-4704-a297-d20e3a857c9c", "exec": [ "" ], "type": "text/javascript" } }, { "listen": "test", "script": { "id": "793f078c-84cd-43e7-b040-d40491fb5a44", "exec": [ "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/environments/{{staging_environment_id}}", "host": [ "{{host}}" ], "path": [ "v2", "environments", "{{staging_environment_id}}" ] } }, "response": [] }, { "name": "Get the Datafile for an Environment", "event": [ { "listen": "prerequest", "script": { "id": "7f337f5a-7ec5-4704-a297-d20e3a857c9c", "exec": [ "" ], "type": "text/javascript" } }, { "listen": "test", "script": { "id": "04f02f5d-c3d7-48af-88f6-45385a313e29", "exec": [ "let response = pm.response.json()", "", "pm.test(\"response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", "pm.test(\"important data is set\", function () {", " pm.expect(response.accountId).to.equal(pm.variables.get(\"account_id\").toString());", " pm.expect(response.projectId).to.equal(pm.variables.get(\"project_id\").toString());", "});" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{host}}/v2/environments/{{staging_environment_id}}/datafile", "host": [ "{{host}}" ], "path": [ "v2", "environments", "{{staging_environment_id}}", "datafile" ] } }, "response": [] }, { "name": "List Environments", "event": [ { "listen": "test", "script": { "id": "10715109-cc56-4271-a4d4-4c48e1bd3542", "exec": [ "let response = pm.response.json()", "for (var i = 0; i