> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://contentful.com/developers/docs/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://contentful.com/_mcp/server. # Create a profile POST https://experience.ninetailed.co/v2/organizations/{organizationId}/environments/{environmentSlug}/profiles Content-Type: application/json Creates or updates a profile and returns it with selected experience variants. The `organizationId` is the **Client ID** from **Settings → SDK Keys → Optimization**. Reference: https://contentful.com/developers/docs/references/experience-api/profiles/create-a-profile ## Request ### Path parameters - `environmentSlug` (string, required, default: main) — The slug of the environment of the profile to retrieve - `organizationId` (string, required) — The ID of the organization of the profile to retrieve ### Query parameters - `locale` (string, optional, default: en) — An ISO 639-1 language code used for experience evaluation. - `type` (enum, optional) — Set to `preflight` to evaluate experiences without persisting state. Useful for SSR/ESR. - Allowed values: `preflight` ### Body (application/json) This endpoint expects an event. - `events` (list of EventEventsItems, optional) ## Response ### 200 Successful response ## Errors ### 400 Bad Request Error Bad Request - `message` (string, required) - `data` (BadRequestData, required) - `error` (BadRequestError, optional) ### 404 Not Found Error Organization or environment not found - `CreateAProfileRequestNotFoundError` ### 429 Too Many Requests Error Profile overload - `CreateAProfileRequestTooManyRequestsError` ### 500 Internal Server Error Internal server error - `message` (string, required) - `data` (InternalServerErrorData, required) - `error` (InternalServerErrorError, optional) ## Types ### EventEventsItems - `channel` (string, required) - `context` (EventEventsItemsContext, required) - `messageId` (string, required) - `type` (enum, required) - Allowed values: `page`, `track`, `identify`, `screen`, `component` - `anonymousId` (string, optional) - `properties` (EventEventsItems, optional) ### BadRequestData ### BadRequestError - `code` (string, optional) ### configNotFoundError - `message` (string, required) - `data` (ConfigNotFoundErrorData, required) - `error` (ConfigNotFoundErrorError, optional) ### notFoundError - `message` (string, required) - `data` (NotFoundErrorData, required) - `error` (NotFoundErrorError, optional) ### profileOverloadError - `message` (string, required) - `data` (ProfileOverloadErrorData, required) - `error` (ProfileOverloadErrorError, optional) ### tooManyRequests - `message` (string, required) - `data` (TooManyRequestsData, required) - `error` (TooManyRequestsError, optional) ### InternalServerErrorData ### InternalServerErrorError - `code` (string, optional) ### EventEventsItemsContext - `app` (EventEventsItemsContextApp, optional) - `library` (EventEventsItemsContextLibrary, optional) - `userAgent` (string, optional) - `campaign` (EventEventsItemsContextCampaign, optional) - `locale` (string, optional) - `page` (EventEventsItemsContextPage, optional) ### ConfigNotFoundErrorData ### ConfigNotFoundErrorError - `code` (string, optional) ### NotFoundErrorData ### NotFoundErrorError - `code` (string, optional) ### ProfileOverloadErrorData ### ProfileOverloadErrorError - `code` (string, optional) ### TooManyRequestsData ### TooManyRequestsError - `code` (string, optional) ### EventEventsItemsContextApp - `name` (string, required) - `version` (string, required) ### EventEventsItemsContextLibrary - `name` (string, required) - `version` (string, required) ### EventEventsItemsContextCampaign ### EventEventsItemsContextPage - `path` (string, optional) - `query` (EventEventsItemsContextPageQuery, optional) - `referrer` (string, optional) - `search` (string, optional) - `url` (string, optional) ### EventEventsItemsContextPageQuery - `utm_campaign` (string, optional) - `utm_content` (string, optional) ## Examples **Request** ```json { "events": [ { "channel": "web", "context": { "app": { "name": "Ninetailed Analytics SDK", "version": "1.0.0" }, "library": { "name": "Ninetailed Analytics SDK", "version": "1.0.0" }, "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", "campaign": {}, "locale": "en-US", "page": { "path": "/", "query": { "utm_campaign": "example_campaign", "utm_content": "example_content" }, "referrer": "", "search": "?utm_campaign=example_campaign&utm_content=example_content", "url": "https://example.com/?utm_campaign=example_campaign&utm_content=example_content" } }, "messageId": "abcd1234-efgh-5678-90ab-cdef11122222", "type": "page", "properties": { "hash": "", "height": 1080, "path": "/", "query": { "utm_campaign": "example_campaign", "utm_content": "example_content" }, "referrer": "", "search": "?utm_campaign=example_campaign&utm_content=example_content", "title": "Sample Page", "url": "https://example.com/?utm_campaign=example_campaign&utm_content=example_content", "width": 1920 } } ] } ``` **Response** ```json { "data": { "changes": [], "experiences": [ { "experienceId": "exp-1", "variantIndex": 0, "variants": { "entryA": "entryA" } } ], "profile": { "audiences": [], "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "location": { "city": "Berlin", "continent": "EU", "country": "Germany", "countryCode": "DE", "region": "Berlin", "timezone": "Europe/Berlin" }, "random": 0.42, "session": { "activeSessionLength": 0, "averageSessionLength": 0, "count": 1, "id": "sess-1234", "isReturningVisitor": false, "landingPage": { "path": "/", "query": { "utm_campaign": "example_campaign", "utm_content": "example_content" }, "referrer": "", "search": "?utm_campaign=example_campaign&utm_content=example_content", "url": "https://example.com/?utm_campaign=example_campaign&utm_content=example_content" } }, "stableId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "traits": {} } }, "error": null, "message": "ok" } ``` **SDK Code** ```javascript JavaScript const response = await fetch('https://experience.ninetailed.co/v2/organizations/{organizationId}/environments/{environmentSlug}/profiles', { method: 'POST', headers: { "Content-Type": "application/json" }, body: JSON.stringify({ "events": [ { "channel": "web", "context": { "app": { "name": "Ninetailed Analytics SDK", "version": "1.0.0" }, "library": { "name": "Ninetailed Analytics SDK", "version": "1.0.0" }, "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", "campaign": {}, "locale": "en-US", "page": { "path": "/", "query": { "utm_campaign": "example_campaign", "utm_content": "example_content" }, "referrer": "", "search": "?utm_campaign=example_campaign&utm_content=example_content", "url": "https://example.com/?utm_campaign=example_campaign&utm_content=example_content" } }, "messageId": "abcd1234-efgh-5678-90ab-cdef11122222", "type": "page", "properties": { "title": "Sample Page", "url": "https://example.com/?utm_campaign=example_campaign&utm_content=example_content", "path": "/", "hash": "", "search": "?utm_campaign=example_campaign&utm_content=example_content", "width": "1920", "height": "1080", "query": { "utm_campaign": "example_campaign", "utm_content": "example_content" }, "referrer": "" } } ] }), }); const data = await response.json(); ``` ```python Python import requests response = requests.post( "https://experience.ninetailed.co/v2/organizations/{organizationId}/environments/{environmentSlug}/profiles", headers={"Content-Type":"application/json"}, json={"events":[{"channel":"web","context":{"app":{"name":"Ninetailed Analytics SDK","version":"1.0.0"},"library":{"name":"Ninetailed Analytics SDK","version":"1.0.0"},"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36","campaign":{},"locale":"en-US","page":{"path":"/","query":{"utm_campaign":"example_campaign","utm_content":"example_content"},"referrer":"","search":"?utm_campaign=example_campaign&utm_content=example_content","url":"https://example.com/?utm_campaign=example_campaign&utm_content=example_content"}},"messageId":"abcd1234-efgh-5678-90ab-cdef11122222","type":"page","properties":{"title":"Sample Page","url":"https://example.com/?utm_campaign=example_campaign&utm_content=example_content","path":"/","hash":"","search":"?utm_campaign=example_campaign&utm_content=example_content","width":"1920","height":"1080","query":{"utm_campaign":"example_campaign","utm_content":"example_content"},"referrer":""}}}]} ) data = response.json() ``` ```http HTTP POST /v2/organizations/{organizationId}/environments/{environmentSlug}/profiles HTTP/1.1 Host: experience.ninetailed.co Content-Type: application/json Accept: */* { "events": [ { "channel": "web", "context": { "app": { "name": "Ninetailed Analytics SDK", "version": "1.0.0" }, "library": { "name": "Ninetailed Analytics SDK", "version": "1.0.0" }, "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36", "campaign": {}, "locale": "en-US", "page": { "path": "/", "query": { "utm_campaign": "example_campaign", "utm_content": "example_content" }, "referrer": "", "search": "?utm_campaign=example_campaign&utm_content=example_content", "url": "https://example.com/?utm_campaign=example_campaign&utm_content=example_content" } }, "messageId": "abcd1234-efgh-5678-90ab-cdef11122222", "type": "page", "properties": { "title": "Sample Page", "url": "https://example.com/?utm_campaign=example_campaign&utm_content=example_content", "path": "/", "hash": "", "search": "?utm_campaign=example_campaign&utm_content=example_content", "width": "1920", "height": "1080", "query": { "utm_campaign": "example_campaign", "utm_content": "example_content" }, "referrer": "" } } ] } ```