### Install Adobe I/O Target SDK Source: https://github.com/adobe/aio-lib-target/blob/master/docs/readme_template.md Install the SDK using npm. This command installs the necessary packages for the project. ```bash npm install ``` -------------------------------- ### Get Offers Source: https://github.com/adobe/aio-lib-target/blob/master/docs/readme_template.md Fetches a list of offers from Adobe Target. ```APIDOC ## Get Offers ### Description Retrieves a list of offers from Adobe Target. ### Method `targetClient.getOffers(options)` ### Parameters #### Query Parameters - **limit** (number) - Optional - The maximum number of offers to return. - **offset** (number) - Optional - The number of offers to skip before starting to collect the result set. ### Request Example ```javascript const offers = await targetClient.getOffers({limit:5, offset:0}) ``` ### Response #### Success Response (Array of Offers) Returns an array of offer objects. ``` -------------------------------- ### Get Environments Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a list of environments configured in Adobe Target. ```APIDOC ## TargetCoreAPI.getEnvironments([options]) ### Description Retrieves a list of environments configured in Adobe Target. ### Method instance method of TargetCoreAPI ### Parameters #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Get Activities Source: https://github.com/adobe/aio-lib-target/blob/master/docs/readme_template.md Fetches a list of activities from Adobe Target. ```APIDOC ## Get Activities ### Description Retrieves a list of activities from Adobe Target. ### Method `targetClient.getActivities(options)` ### Parameters #### Query Parameters - **limit** (number) - Optional - The maximum number of activities to return. - **offset** (number) - Optional - The number of activities to skip before starting to collect the result set. ### Request Example ```javascript const activities = await targetClient.getActivities({limit:5, offset:0}) ``` ### Response #### Success Response (Array of Activities) Returns an array of activity objects. ``` -------------------------------- ### Get MBoxes Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a list of MBoxes configured in Adobe Target. ```APIDOC ## TargetCoreAPI.getMBoxes([options]) ### Description Retrieves a list of MBoxes configured in Adobe Target. ### Method instance method of TargetCoreAPI ### Parameters #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Get a single offer by ID Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves the full content of a specific offer by its ID. Ensure the client is initialized before use. ```javascript const res = await client.getOfferById(391769) // res.status === 200 const offer = res.body console.log(offer.name) // => '10OFF' console.log(offer.content) // => 'Use 10OFF for $10 off for orders over $100' ``` -------------------------------- ### Get Offer By ID Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a specific offer by its ID. ```APIDOC ## TargetCoreAPI.getOfferById(id, [options]) ### Description Retrieves a specific offer by its ID. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the offer. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Get Properties Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a list of properties configured in Adobe Target. ```APIDOC ## TargetCoreAPI.getProperties([options]) ### Description Retrieves a list of properties configured in Adobe Target. ### Method instance method of TargetCoreAPI ### Parameters #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Get MBox By Name Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a specific MBox by its name. ```APIDOC ## TargetCoreAPI.getMBoxByName(name, [options]) ### Description Retrieves a specific MBox by its name. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **name** (string) - Required - The name of the MBox. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Set Activity Schedule using Client Source: https://context7.com/adobe/aio-lib-target/llms.txt Updates the start and/or end times for an activity by its ID. Useful for scheduling campaigns. ```javascript const schedule = { startsAt: '2024-03-01T08:00Z', endsAt: '2024-09-01T07:59:59Z' } const res = await client.setActivitySchedule(168805, schedule) // res.status === 200 console.log(res.body.startsAt) // => '2024-03-01T08:00Z' ``` -------------------------------- ### Get Offer By ID Source: https://github.com/adobe/aio-lib-target/blob/master/docs/readme_template.md Fetches a specific offer by its ID from Adobe Target. ```APIDOC ## Get Offer By ID ### Description Retrieves a specific offer by its ID from Adobe Target. ### Method `targetClient.getOfferById(offerId)` ### Parameters #### Path Parameters - **offerId** (number) - Required - The ID of the offer to retrieve. ### Request Example ```javascript const offer = await targetClient.getOfferById(123) ``` ### Response #### Success Response (Offer Object) Returns the offer object corresponding to the provided ID. ``` -------------------------------- ### Get Activity Performance Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves general performance data for a specific activity. ```APIDOC ## TargetCoreAPI.getActivityPerformance(id, [options]) ### Description Retrieves general performance data for a specific activity. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the activity. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Safely Get AB Activity by ID with Error Handling Source: https://context7.com/adobe/aio-lib-target/llms.txt This function demonstrates how to safely retrieve an A/B activity by its ID using the Target SDK. It includes specific error handling for 'Activity not found or unauthorized' and 'SDK was not initialized correctly' errors, re-throwing any other unexpected errors. ```javascript const { codes } = require('@adobe/aio-lib-target/src/SDKErrors') async function safeGetActivity (client, id) { try { const res = await client.getABActivityById(id) return res.body } catch (err) { if (err.code === 'ERROR_GET_AB_ACTIVITY_BY_ID') { console.error('Activity not found or unauthorized:', err.message) } else if (err.code === 'ERROR_SDK_INITIALIZATION') { console.error('SDK was not initialized correctly:', err.message) } else { throw err // re-throw unexpected errors } return null } } ``` -------------------------------- ### Get XT Activity by ID using Client Source: https://context7.com/adobe/aio-lib-target/llms.txt Fetches the full definition of an Experience Targeting (XT) activity by its numeric ID. Useful for inspecting or retrieving activity details. ```javascript const res = await client.getXTActivityById(321) // res.status === 200 const xt = res.body console.log(xt.name) // => 'New XT Activity' console.log(xt.state) // => 'saved' console.log(xt.locations.mboxes[0].name) // => 'x1-serverside-ab' ``` -------------------------------- ### Get Target Activities Source: https://github.com/adobe/aio-lib-target/blob/master/docs/readme_template.md Retrieve a list of activities from Adobe Target. This method accepts optional limit and offset parameters for pagination. ```javascript var sdk = require('@adobe/aio-lib-target') async function sdkTest() { //initialize sdk const targetClient = await sdk.init('', 'x-api-key', '') //get activities const activities = await targetClient.getActivities({limit:5, offset:0}) console.log(util.inspect(activities)); //get offers const offers = await targetClient.getOffers({limit:5, offset:0}) console.log(util.inspect(offers)); //get offer by id activity const offer = await targetClient.getOfferById(123) console.log(util.inspect(offer)); } ``` -------------------------------- ### Get orders/audit report Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves the orders and audit report data for an AB, XT, or Automated Personalization activity. The response includes report parameters and activity details. ```javascript const res = await client.getOrdersReport(123) // res.status === 200 const { reportParameters, activity } = res.body console.log('Activity type:', activity.type) // => 'xt' console.log('Environment:', reportParameters.environmentId) // => 8818 ``` -------------------------------- ### Get XT activity performance report Source: https://context7.com/adobe/aio-lib-target/llms.txt Returns the performance report for an Experience Targeting activity with the same structure as the AB report. The response includes activity details and the report data. ```javascript const res = await client.getXTActivityPerformance(123) // res.status === 200 const { activity, report } = res.body console.log('Activity:', activity.name) // => 'Master - Serverside - XT' console.log('Visit entries:', report.statistics.totals.visit.totals.entries) // => 52 ``` -------------------------------- ### Get AB activity performance report Source: https://context7.com/adobe/aio-lib-target/llms.txt Returns the performance report for an AB activity, including visitor/visit totals and conversion data per experience. The response includes report parameters, activity details, and the report itself. ```javascript const res = await client.getABActivityPerformance(111) // res.status === 200 const { reportParameters, activity, report } = res.body console.log('Activity:', activity.name) // => 'Master - Mobile - AB' console.log('Entries:', report.statistics.totals.visitor.totals.entries) // => 115 console.log('Conversions:', report.statistics.totals.visitor.totals.conversions) // => 0 ``` -------------------------------- ### init(tenant, apiKey, token) Source: https://context7.com/adobe/aio-lib-target/llms.txt Initializes the SDK client with tenant name, API key, and Bearer token. Returns a Promise that resolves to a configured TargetCoreAPI instance. Throws an error if any required credential is missing. ```APIDOC ## init(tenant, apiKey, token) ### Description Initializes the SDK client with tenant name, API key, and Bearer token. Returns a Promise that resolves to a configured TargetCoreAPI instance. Throws an error if any required credential is missing. ### Method `init` ### Parameters - **tenant** (string) - Required - Adobe Target tenant name - **apiKey** (string) - Required - x-api-key credential - **token** (string) - Required - Valid IMS Bearer token ### Returns - `Promise` - A Promise that resolves to the initialized SDK client. ### Throws - `ERROR_SDK_INITIALIZATION` - If any of the required credentials are missing. ### Example ```javascript const sdk = require('@adobe/aio-lib-target') async function main () { const client = await sdk.init( 'mycompany', 'my-api-key-abc123', 'eyJhbGciOiJSUzI...' ) console.log(client.tenant) } main().catch(err => { console.error('Init failed:', err.message) }) ``` ``` -------------------------------- ### init Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Initializes and returns a new TargetCoreAPI object with the provided tenant, API key, and token. ```APIDOC ## init(tenant, apiKey, token) ### Description Returns a Promise that resolves with a new TargetCoreAPI object. ### Method init ### Parameters #### Path Parameters - **tenant** (string) - Required - tenant Adobe Target tenant name - **apiKey** (string) - Required - apiKey Your api key - **token** (string) - Required - Valid auth token ### Response #### Success Response - [TargetCoreAPI] - Promise resolving to a TargetCoreAPI instance ``` -------------------------------- ### Get Property By ID Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a specific property by its ID. ```APIDOC ## TargetCoreAPI.getPropertyById(id, [options]) ### Description Retrieves a specific property by its ID. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the property. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Initializing the SDK Source: https://github.com/adobe/aio-lib-target/blob/master/docs/readme_template.md Initializes the Target SDK with tenant, API key, and authentication token. ```APIDOC ## Initialize SDK ### Description Initializes the Target SDK client. ### Method `sdk.init(tenant, apiKey, token)` ### Parameters #### Path Parameters - **tenant** (string) - Required - Your Adobe Target tenant name. - **apiKey** (string) - Required - Your Adobe Target API key. - **token** (string) - Required - A valid authentication token. ### Request Example ```javascript var sdk = require('@adobe/aio-lib-target') async function initializeSdk() { const targetClient = await sdk.init('', 'x-api-key', '') return targetClient; } ``` ### Response #### Success Response (Instance of TargetCoreAPI) Returns an instance of the TargetCoreAPI class which can be used to make further calls. ``` -------------------------------- ### Get Audience By ID Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a specific audience by its ID. ```APIDOC ## TargetCoreAPI.getAudienceById(id, [options]) ### Description Retrieves a specific audience by its ID. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the audience. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Initialize Target SDK Source: https://github.com/adobe/aio-lib-target/blob/master/docs/readme_template.md Initialize the SDK with tenant, API key, and authentication token. The init method returns an instance of TargetCoreAPI. ```javascript var sdk = require('@adobe/aio-lib-target') async function sdkTest() { //initialize sdk const targetClient = await sdk.init('', 'x-api-key', '') } ``` -------------------------------- ### TargetCoreAPI Initialization Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Initializes the TargetCoreAPI instance with tenant, API key, and authentication token. ```APIDOC ## targetCoreAPI.init(tenant, apiKey, token) ### Description Initialize sdk. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **tenant** (string) - Required - Adobe Target tenant name - **apiKey** (string) - Required - Your api key - **token** (string) - Required - Valid auth token ### Returns - **TargetCoreAPI** - a TargetCoreAPI instance ``` -------------------------------- ### Initialize the Target SDK Client Source: https://context7.com/adobe/aio-lib-target/llms.txt Initializes the Target SDK client with tenant name, API key, and Bearer token. All three parameters are required. Throws an error if any argument is missing. ```javascript const sdk = require('@adobe/aio-lib-target') async function main () { // All three parameters are required const client = await sdk.init( 'mycompany', 'my-api-key-abc123', 'eyJhbGciOiJSUzI...' ) console.log(client.tenant) console.log(client.apiKey) } main().catch(err => { // err.name === 'TargetSDKError' // err.code === 'ERROR_SDK_INITIALIZATION' console.error('Init failed:', err.message) }) ``` -------------------------------- ### Get Orders Report Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves the orders report for a specific activity. ```APIDOC ## TargetCoreAPI.getOrdersReport(id, [options]) ### Description Retrieves the orders report for a specific activity. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the activity. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Initialize SDK Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Initializes the Adobe Target SDK client with tenant, API key, and authentication token. ```APIDOC ## init ### Description Returns a Promise that resolves with a new TargetCoreAPI object. ### Method init(tenant, apiKey, token) ### Parameters - **tenant** (string) - The tenant identifier. - **apiKey** (string) - The API key for authentication. - **token** (string) - A valid authentication token. ### Returns - Promise<TargetCoreAPI> - A promise that resolves to a TargetCoreAPI instance. ``` -------------------------------- ### getOffers(options) Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves all content offers with optional pagination and sorting. Uses the `v2` Accept header. ```APIDOC ## getOffers(options) ### Description Retrieves all content offers with optional pagination and sorting. Uses the `v2` Accept header. ### Method `getOffers` ### Parameters - **options** (object) - Optional - Pagination and sorting options. - **limit** (number) - Optional - The maximum number of offers to return. - **offset** (number) - Optional - The offset for pagination. - **sortBy** (string) - Optional - The field to sort offers by (e.g., 'modifiedAt'). ### Response #### Success Response (200) - **body** (object) - Contains a list of content offers. - **total** (number) - The total number of offers available. - **offset** (number) - The offset used for pagination. - **limit** (number) - The limit used for pagination. - **offers** (array) - An array of offer objects. - **type** (string) - The type of the offer (e.g., 'content'). - **name** (string) - The name of the offer. ### Response Example ```javascript const res = await client.getOffers({ limit: 5, offset: 0, sortBy: 'modifiedAt' }) // res.status === 200 // res.body => { total: 2, offset: 0, limit: 5, offers: [...] } const contentOffers = res.body.offers.filter(o => o.type === 'content') console.log(contentOffers[0].name) // => '/l1_a_b_test/experiences/0/...' ``` ``` -------------------------------- ### targetCoreAPI.getEnvironments Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Lists all available environments with options to filter and sort. ```APIDOC ## targetCoreAPI.getEnvironments ### Description Lists all available environments with the options to filter and sort. Use the Environments API to retrieve the environment IDs corresponding to the various host groups set for the client. ### Method GET (assumed, based on typical REST API patterns for listing resources) ### Endpoint /rest/web/v1/environments (assumed, based on typical Target API structure) ### Parameters #### Query Parameters - **options** (object) - Optional - SDK options, including headers. - **options.headers** (object) - Optional - Headers to pass to the API call. ### Response #### Success Response (200) - **Response** (object) - A promise resolving to a Response object. ### Request Example ```javascript // Example usage (actual implementation may vary based on SDK context) targetCoreAPI.getEnvironments({ headers: { 'Authorization': 'Bearer YOUR_TOKEN' } }) .then(response => { console.log(response); }) .catch(error => { console.error(error); }); ``` ``` -------------------------------- ### List Content Offers using Client Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves all content offers with optional pagination and sorting parameters. This method uses the `v2` Accept header. ```javascript const res = await client.getOffers({ limit: 5, offset: 0, sortBy: 'modifiedAt' }) // res.status === 200 // res.body => { total: 2, offset: 0, limit: 5, offers: [...] } const contentOffers = res.body.offers.filter(o => o.type === 'content') console.log(contentOffers[0].name) // => '/l1_a_b_test/experiences/0/...' ``` -------------------------------- ### Get Audiences Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a list of audiences defined in Adobe Target. ```APIDOC ## TargetCoreAPI.getAudiences([options]) ### Description Retrieves a list of audiences defined in Adobe Target. ### Method instance method of TargetCoreAPI ### Parameters #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### createOffer Source: https://context7.com/adobe/aio-lib-target/llms.txt Creates a new content offer. The body must include at minimum a `name` and `content` property. ```APIDOC ## createOffer(body, options) ### Description Creates a new content offer. The body must include at minimum a `name` and `content` property. ### Method POST ### Endpoint /offers ### Parameters #### Request Body - **body** (object) - Required - The offer object to create. - **name** (string) - Required - The name of the offer. - **content** (string) - Required - The content of the offer. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ### Request Example ```javascript const newOffer = { name: 'Summer Sale Banner', content: '' } const res = await client.createOffer(newOffer) ``` ### Response #### Success Response (200) - **body** (object) - The created offer object, including its `id`. #### Response Example ```json { "id": 123, "name": "Summer Sale Banner", "content": "
Save 20% this summer!
" } ``` ``` -------------------------------- ### createXTActivity(body, options) Source: https://context7.com/adobe/aio-lib-target/llms.txt Creates an Experience Targeting activity. XT activities allow targeting different experiences to different audience segments. ```APIDOC ## createXTActivity(body, options) ### Description Creates an Experience Targeting activity. XT activities allow targeting different experiences to different audience segments. ### Method `createXTActivity` ### Parameters - **body** (object) - Required - The definition of the XT activity to create. - **name** (string) - Required - The name of the activity. - **state** (string) - Required - The initial state of the activity (e.g., 'saved'). - **priority** (number) - Required - The priority of the activity. - **startsAt** (string) - Required - The start date and time for the activity in ISO 8601 format. - **endsAt** (string) - Required - The end date and time for the activity in ISO 8601 format. - **autoAllocateTraffic** (object) - Optional - Configuration for automatic traffic allocation. - **enabled** (boolean) - Required - Whether to enable automatic traffic allocation. - **successEvaluationCriteria** (string) - Required - The criteria for evaluating success (e.g., 'conversion_rate'). - **locations** (object) - Required - Defines the locations where the activity will be applied. - **mboxes** (array) - Required - An array ofmbox configurations. - **locationLocalId** (number) - Required - The local ID of the mbox. - **name** (string) - Required - The name of the mbox. - **options** (object) - Optional - Additional options for the request. ### Response #### Success Response (200) - **body** (object) - Contains the ID of the newly created XT activity. - **id** (number) - The ID of the created activity. ### Request Example ```javascript const xtBody = { name: 'US vs EU Landing Page', state: 'saved', priority: 200, startsAt: '2024-02-01T00:00Z', endsAt: '2024-08-01T00:00Z', autoAllocateTraffic: { enabled: false, successEvaluationCriteria: 'conversion_rate' }, locations: { mboxes: [{ locationLocalId: 0, name: 'landing-page-hero' }] } } const res = await client.createXTActivity(xtBody) // res.status === 200 console.log('XT Activity ID:', res.body.id) ``` ``` -------------------------------- ### List all properties Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves all workspace properties defined in the account. Uses the `v1` Accept header. The response includes pagination details and a list of properties. ```javascript const res = await client.getProperties() // res.status === 200 // res.body => { total: 2, offset: 0, limit: 10, properties: [...] } for (const prop of res.body.properties) { console.log(`${prop.id}: ${prop.name} (${prop.channel})`) } // => 2: Products pagde (web) // => 1: Products page (web) ``` -------------------------------- ### createABActivity(body, options) Source: https://context7.com/adobe/aio-lib-target/llms.txt Creates an AB (A/B Test) activity from a JSON body describing the activity definition, locations, experiences, and metrics. Returns the newly-created activity object. ```APIDOC ## createABActivity(body, options) ### Description Creates an AB (A/B Test) activity from a JSON body describing the activity definition, locations, experiences, and metrics. Returns the newly-created activity object. ### Method `createABActivity` ### Parameters #### Request Body - **body** (object) - Required - The JSON object describing the AB activity definition. - `name` (string) - Required - The name of the activity. - `state` (string) - Required - The state of the activity (e.g., 'saved', 'running'). - `priority` (number) - Required - The priority of the activity. - `startsAt` (string) - Optional - The start date and time of the activity in ISO 8601 format. - `endsAt` (string) - Optional - The end date and time of the activity in ISO 8601 format. - `autoAllocateTraffic` (object) - Optional - Configuration for automatic traffic allocation. - `enabled` (boolean) - Required - Whether automatic traffic allocation is enabled. - `successEvaluationCriteria` (string) - Required - The criteria for success evaluation (e.g., 'conversion_rate'). - `locations` (object) - Required - The locations for the activity. - `mboxes` (array) - Required - An array of mbox configurations. - `locationLocalId` (number) - Required - The local ID of the mbox. - `name` (string) - Required - The name of the mbox. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ### Returns - `Promise` - A Promise that resolves to a response object containing the newly created AB activity. - `body.id` (string) - The ID of the created activity. ### Throws - `ERROR_CREATE_AB_ACTIVITY` - If the activity creation fails. ### Example ```javascript const newActivity = { name: 'Homepage Banner Test', state: 'saved', priority: 100, startsAt: '2024-01-01T08:00Z', endsAt: '2024-06-01T07:59:59Z', autoAllocateTraffic: { enabled: false, successEvaluationCriteria: 'conversion_rate' }, locations: { mboxes: [{ locationLocalId: 0, name: 'homepage-hero' }] } } try { const res = await client.createABActivity(newActivity) console.log('Created activity ID:', res.body.id) } catch (err) { console.error(err.message) } ``` ``` -------------------------------- ### Get XT Activity By ID Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a specific cross-treatment (XT) activity by its ID. ```APIDOC ## TargetCoreAPI.getXTActivityById(id, [options]) ### Description Retrieves a specific cross-treatment (XT) activity by its ID. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the XT activity. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Create a new content offer Source: https://context7.com/adobe/aio-lib-target/llms.txt Creates a new content offer. The body must include at minimum a `name` and `content` property. Handle potential errors during creation. ```javascript const newOffer = { name: 'Summer Sale Banner', content: '' } try { const res = await client.createOffer(newOffer) // res.status === 200 console.log('New offer ID:', res.body.id) // => 123 } catch (err) { // err.code === 'ERROR_CREATE_OFFER' console.error(err.message) } ``` -------------------------------- ### Get AB Activity By ID Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a specific A/B test activity by its ID. ```APIDOC ## TargetCoreAPI.getABActivityById(id, [options]) ### Description Retrieves a specific A/B test activity by its ID. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the A/B activity. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### setActivitySchedule(id, schedule, options) Source: https://context7.com/adobe/aio-lib-target/llms.txt Updates the start and/or end schedule of an activity. ```APIDOC ## setActivitySchedule(id, schedule, options) ### Description Updates the start and/or end schedule of an activity. ### Method `setActivitySchedule` ### Parameters - **id** (number) - Required - The ID of the activity. - **schedule** (object) - Required - An object containing the updated schedule. - **startsAt** (string) - Optional - The new start date and time in ISO 8601 format. - **endsAt** (string) - Optional - The new end date and time in ISO 8601 format. - **options** (object) - Optional - Additional options for the request. ### Response #### Success Response (200) - **body** (object) - Contains the updated schedule of the activity. - **startsAt** (string) - The new start date and time. - **endsAt** (string) - The new end date and time. ### Request Example ```javascript const schedule = { startsAt: '2024-03-01T08:00Z', endsAt: '2024-09-01T07:59:59Z' } const res = await client.setActivitySchedule(168805, schedule) // res.status === 200 console.log(res.body.startsAt) // => '2024-03-01T08:00Z' ``` ``` -------------------------------- ### Get XT Activity Performance Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves performance data for a specific cross-treatment (XT) activity. ```APIDOC ## TargetCoreAPI.getXTActivityPerformance(id, [options]) ### Description Retrieves performance data for a specific cross-treatment (XT) activity. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the XT activity. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### targetCoreAPI.getMBoxes Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Lists all available mboxes for a specific client with options to filter and sort. ```APIDOC ## targetCoreAPI.getMBoxes ### Description Lists all available mboxes for a specific client with the options to filter and sort. ### Method GET (assumed, based on typical REST API patterns for listing resources) ### Endpoint /rest/web/v1/mbox (assumed, based on typical Target API structure) ### Parameters #### Query Parameters - **options** (object) - Optional - SDK options, including headers. - **options.headers** (object) - Optional - Headers to pass to the API call. ### Response #### Success Response (200) - **Response** (object) - A promise resolving to a Response object. ### Request Example ```javascript // Example usage (actual implementation may vary based on SDK context) targetCoreAPI.getMBoxes({ headers: { 'Authorization': 'Bearer YOUR_TOKEN' } }) .then(response => { console.log(response); }) .catch(error => { console.error(error); }); ``` ``` -------------------------------- ### getOffers Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Lists all available offers with options for filtering and sorting. This is useful for retrieving a collection of offers for display or further processing. ```APIDOC ## getOffers([options]) ### Description List Offers. Retrieve the list of previously-created content offers. The parameters passed through the query string are optional and are used to indicate the sorting and filtering options. ### Method GET (assumed based on operation) ### Endpoint /offers (assumed based on operation) ### Parameters #### Query Parameters - **options** (object) - Optional - To control offer search. - **limit** (number) - Optional - Defines the number of items to return. Default: 2147483647. - **offset** (number) - Optional - Defines the first offers to return from the list of Offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers. Default: 0. - **sortBy** (string) - Optional - Defines the sorting criteria on the returned items. - **headers** (object) - Optional - Headers to pass to API call. ### Response #### Success Response (200) - **Response** (Promise) - A Promise resolving to a Response object. ### Request Example ```javascript // Example usage (assuming TargetCoreAPI instance is available as targetCoreAPI) targetCoreAPI.getOffers({ limit: 10, sortBy: 'name', headers: { 'Authorization': 'Bearer YOUR_TOKEN' } }) .then(response => console.log(response)) .catch(error => console.error(error)); ``` ``` -------------------------------- ### Get AB Activity Performance Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves performance data for a specific A/B test activity. ```APIDOC ## TargetCoreAPI.getABActivityPerformance(id, [options]) ### Description Retrieves performance data for a specific A/B test activity. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the A/B activity. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### List all environments Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves all host group environments (e.g., Production, Staging, Development) with their IDs. The response body includes total count, offset, limit, and a list of environment objects. ```javascript const res = await client.getEnvironments() // res.status === 200 // res.body => { total: 3, offset: 0, limit: 2147483647, environments: [...] } for (const env of res.body.environments) { console.log(`${env.id}: ${env.name}`) } // => 8820: Development // => 8818: Production // => 8819: Staging ``` -------------------------------- ### Get MBox Profile Attributes Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves profile attributes associated with MBoxes in Adobe Target. ```APIDOC ## TargetCoreAPI.getMBoxProfileAttributes([options]) ### Description Retrieves profile attributes associated with MBoxes in Adobe Target. ### Method instance method of TargetCoreAPI ### Parameters #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Get Activity Change Log Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves the change log for a specific Adobe Target activity. ```APIDOC ## TargetCoreAPI.getActivityChangeLog(id, [options]) ### Description Retrieves the change log for a specific Adobe Target activity. ### Method instance method of TargetCoreAPI ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the activity. #### Query Parameters - **options** (object) - Optional - Additional options for the request. ``` -------------------------------- ### Get a single property by ID Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves the full definition of a workspace property by its numeric ID. Requires the property `id`. ```javascript const res = await client.getPropertyById(2) // res.status === 200 const prop = res.body console.log(prop.name) // => 'Email property' console.log(prop.channel) // => 'email' console.log(prop.workspaces) // => ['1234567', '12345679'] ``` -------------------------------- ### targetCoreAPI.createABActivity Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Creates a new AB activity with the specified contents and returns the created activity. ```APIDOC ## targetCoreAPI.createABActivity(body, [options]) ### Description Create AB Activity. Creates a new AB activity with the specified contents and returns the created activity. ### Method POST (assumed, based on 'create' operation) ### Endpoint /activities/ab (assumed, based on 'create AB Activity' context) ### Parameters #### Request Body - **body** (object) - Required - Activity JSON. #### Query Parameters - **options** (object) - Optional - SDK options. - **headers** (object) - Optional - Headers to pass to API call. ### Request Example ```json { "body": { "name": "My New AB Test", "type": "AB", "experienceA": { "name": "Control", "content": "

Welcome!

" }, "experienceB": { "name": "Variant", "content": "

Special Offer!

" }, "trafficType": "ALL", "status": "DRAFT" }, "options": { "headers": { "Authorization": "Bearer YOUR_ACCESS_TOKEN" } } } ``` ### Response #### Success Response (200) - **Response** (object) - A promise resolving to a Response object containing the created activity. ### Response Example ```json { "id": "67890", "name": "My New AB Test", "status": "DRAFT", "type": "AB" } ``` ``` -------------------------------- ### Get a single audience by ID Source: https://context7.com/adobe/aio-lib-target/llms.txt Fetches the full audience definition including targeting rules. Requires the audience `id`. ```javascript const res = await client.getAudienceById(1216090) // res.status === 200 const audience = res.body console.log(audience.name) // => 'Gold Members in Califo-1495136673062' console.log(JSON.stringify(audience.targetRule, null, 2)) // => { "and": [{ "profile": "memberLevel", "equals": ["gold"] }, { "geo": "region", "matches": ["california"] }] } ``` -------------------------------- ### Create XT Activity using Client Source: https://context7.com/adobe/aio-lib-target/llms.txt Creates a new Experience Targeting activity. XT activities are used for targeting different experiences to specific audience segments. Requires a detailed body object. ```javascript const xtBody = { name: 'US vs EU Landing Page', state: 'saved', priority: 200, startsAt: '2024-02-01T00:00Z', endsAt: '2024-08-01T00:00Z', autoAllocateTraffic: { enabled: false, successEvaluationCriteria: 'conversion_rate' }, locations: { mboxes: [{ locationLocalId: 0, name: 'landing-page-hero' }] } } const res = await client.createXTActivity(xtBody) // res.status === 200 console.log('XT Activity ID:', res.body.id) ``` -------------------------------- ### getActivities(options) Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves a paginated list of all activities (AB, XT, Automated Personalization) in the Target account. Supports limit, offset, and sortBy query options. Uses the v3 Accept header. ```APIDOC ## getActivities(options) ### Description Retrieves a paginated list of all activities (AB, XT, Automated Personalization) in the Target account. Supports `limit`, `offset`, and `sortBy` query options. Uses the `v3` Accept header. ### Method `getActivities` ### Parameters #### Query Parameters - **limit** (number) - Optional - The maximum number of activities to return. - **offset** (number) - Optional - The number of activities to skip. - **sortBy** (string) - Optional - The field to sort the activities by (e.g., 'name'). ### Returns - `Promise` - A Promise that resolves to a response object containing a paginated list of activities. - `body.total` (number) - The total number of activities available. - `body.offset` (number) - The current offset. - `body.limit` (number) - The current limit. - `body.activities` (array) - An array of activity objects. ### Example ```javascript const client = await sdk.init(tenant, apiKey, token) const res = await client.getActivities({ limit: 10, offset: 0, sortBy: 'name' }) console.log(res.body.total) for (const activity of res.body.activities) { console.log(`[${activity.type}] ${activity.id}: ${activity.name} (${activity.state})`) } ``` ``` -------------------------------- ### Enable Debug Logs Source: https://github.com/adobe/aio-lib-target/blob/master/docs/readme_template.md Enable debug logging for the SDK by setting the LOG_LEVEL environment variable. This is useful for troubleshooting. ```bash LOG_LEVEL=debug ``` -------------------------------- ### targetCoreAPI.createXTActivity Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Creates a new XT activity with the specified contents and returns the created activity. ```APIDOC ## targetCoreAPI.createXTActivity(body, [options]) ### Description Create XT Activity. Creates a new XT activity with the specified contents and returns the created activity. ### Method POST (assumed, based on 'create' operation) ### Endpoint /activities/xt (assumed, based on 'create XT Activity' context) ### Parameters #### Request Body - **body** (object) - Required - Activity JSON. #### Query Parameters - **options** (object) - Optional - SDK options. - **headers** (object) - Optional - Headers to pass to API call. ### Request Example ```json { "body": { "name": "My New XT Test", "type": "XT", "content": "

Personalized Content

", "status": "DRAFT" }, "options": { "headers": { "Authorization": "Bearer YOUR_ACCESS_TOKEN" } } } ``` ### Response #### Success Response (200) - **Response** (object) - A promise resolving to a Response object containing the created activity. ### Response Example ```json { "id": "11223", "name": "My New XT Test", "status": "DRAFT", "type": "XT" } ``` ``` -------------------------------- ### Get Automated Personalization (AP) activity performance Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves the performance report for an Automated Personalization activity. The response includes report parameters and the report statistics. ```javascript const res = await client.getActivityPerformance(123) // res.status === 200 const { reportParameters, report } = res.body console.log('Report interval:', reportParameters.reportInterval) // => '2017-03-20T16:00Z/2017-07-10T07:00Z' console.log('Visitor entries:', report.statistics.totals.visitor.totals.entries) // => 41 ``` -------------------------------- ### Create a new audience with targeting rules Source: https://context7.com/adobe/aio-lib-target/llms.txt Creates a new audience with the specified targeting rules. The `body` must include `name`, `description`, and `targetRule`. ```javascript const newAudience = { name: 'Premium Mobile Users', description: 'Users with premium plan on mobile devices', targetRule: { and: [ { profile: 'memberLevel', equals: ['premium'] }, { user: 'browserType', equals: ['mobile'] } ] } } const res = await client.createAudience(newAudience) // res.status === 200 console.log('Created audience ID:', res.body.id) ``` -------------------------------- ### List All Activities Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves a paginated list of all activities (AB, XT, Automated Personalization) in the Target account. Supports 'limit', 'offset', and 'sortBy' query options. Uses the 'v3' Accept header. ```javascript const client = await sdk.init(tenant, apiKey, token) // Fetch first 10 activities sorted by name const res = await client.getActivities({ limit: 10, offset: 0, sortBy: 'name' }) // res.status === 200 // res.body => { total: 42, offset: 0, limit: 10, activities: [...] } for (const activity of res.body.activities) { console.log(`[${activity.type}] ${activity.id}: ${activity.name} (${activity.state})`) } // => [ab] 168805: A3 - L4242 - Serversid testing (deactivated) // => [ab] 168816: A5-L4242 (deactivated) ``` -------------------------------- ### Get mbox parameters by name Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves the list of mbox parameters associated with a named mbox. The response body contains the mbox name and an array of mbox parameters. ```javascript const res = await client.getMBoxByName('a1-mobile-mboxparams') // res.status === 200 const mbox = res.body console.log(mbox.name) // => 'a1-mobile-mboxparams' for (const param of mbox.mboxParameters) { console.log(`${param.name} (${param.parameterType})`) } // => a.AppID (MBOX) // => a.CarrierName (MBOX) // => a.CrashEvent (MBOX) ``` -------------------------------- ### targetCoreAPI.getProperties Source: https://github.com/adobe/aio-lib-target/blob/master/README.md Retrieves a list of all available properties. ```APIDOC ## getProperties ### Description Get a list of properties. ### Method GET ### Endpoint /rest/web/properties ### Parameters #### Request Body None ### Response #### Success Response (200) - **properties** (array) - List of properties. - **total** (number) - Total number of properties. #### Response Example { "properties": [ { "id": "prop1", "name": "Property 1" } ], "total": 1 } ``` -------------------------------- ### Get Activity Change Log using Client Source: https://context7.com/adobe/aio-lib-target/llms.txt Retrieves the full audit log for an activity by its ID, detailing state transitions and parameter changes with timestamps. Useful for tracking activity history. ```javascript const res = await client.getActivityChangeLog(168805) // res.status === 200 // res.body => { offset: 0, limit: 2147483647, total: 2, activityChangelogs: [...] } for (const entry of res.body.activityChangelogs) { const { state } = entry.activityParameters console.log(`${entry.modifiedAt}: ${state.previousValue} → ${state.changedValue}`) } // => 2017-05-11T12:16:13Z: approved → saved // => 2017-04-27T14:09:44Z: approved → saved ```