Skip to main content Skip to complementary content
Close announcements banner

Creating a campaign using the API

You can create a campaign by providing the name of the data model and the campaign configuration. You can include the campaign name. It must then match the pattern ^[a-z][a-z\d\-]*$.

The response contains the field id, which is useful for editing the campaign afterward.

In this example, Talend API Tester is used to send requests.

For further information about Talend API Tester, see Talend Cloud API Tester User Guide.

Before you begin

You retrieved the details about the data model to be used in the campaign, using the GET https://tds.{region}.cloud.talend.com/schemaservice/api/v1/schemas/org.talend.schema/{dataModelName} operation.

Procedure

  1. If you do not have a personal access token yet, generate one. For further information, see Generating a Personal Access Token.
  2. Open Talend API Tester in your browser.
  3. From the Repository tab, select Post in the Method drop-down list.
  4. Enter the following URL: https://tds.{region}.cloud.talend.com/data-stewardship/api/v1/campaigns/owned
    You'll find a list of the URLs to use for each data center in Talend Cloud regions and URLs.
  5. Click the Add header button and enter Authorization in the name field and Bearer followed by a whitespace and your token in the value field.
  6. Click the Add header button and enter Cookie in the name field, then leave the value field empty.
  7. In the Body field, include the campaign details in JSON.

    Example

    To create the same Demo - Improve product catalog data quality campaign as the one from the guided tour, using a different name such as my-campaign-resolution-created-via-api and the my_products_created_via_API, enter:
    {
        "campaign": {
            "name": "my-campaign-resolution-created-via-api",
            "label": "Improve product catalog data quality (created via API)",
            "description": "Increase the level of data quality for each product catalog.",
            "owners": ["owner@account.com"],
            "taskType": "RESOLUTION",
            "schemaRef": {
                "namespace": "org.talend.schema",
                "name": "my_products_created_via_API",
                "version": 1,
                "displayName": "Product (created via API)"
            },
            "taskResolutionDelay": {
                "value": 10,
                "unit": "DAYS"
            },
            "workflow": {
                "name": "default workflow",
                "states": [{
                    "name": "New",
                    "label": "New",
                    "transitions": [{
                        "name": "To validate",
                        "label": "To validate",
                        "targetStateName": "To validate",
                        "allowedRoles": ["Supervisor"]
                    }],
                    "allowedRoles": [],
                    "translations": {}
                }, {
                    "name": "To validate",
                    "label": "To validate",
                    "transitions": [{
                        "name": "Accept",
                        "label": "Accept",
                        "targetStateName": "Resolved",
                        "allowedRoles": ["Validator"]
                    }, {
                        "name": "Reject",
                        "label": "Reject",
                        "targetStateName": "New",
                        "allowedRoles": ["Validator"]
                    }],
                    "allowedRoles": [],
                    "translations": {}
                }, {
                    "name": "Resolved",
                    "label": "Resolved",
                    "transitions": [],
                    "allowedRoles": ["Validator"],
                    "translations": {}
                }]
            }
        },
        "participants": {
            "Supervisor": ["steward1@account.com"],
            "Validator": ["steward1@account.com"]
        }
    }

    The "owners" value must include the usernames of the campaign owners.

    The "schemaRef": object must include the "namespace", "name", "version" and "displayName" values for the desired data model. To retrieve this information, see Reading a data model using the API.

    The "Supervisor" and "Validator" value must include the usernames of the desired data stewards for these roles.

  8. Click Send.

Results

The API returns a 200 HTTP code to inform you that the request was successful. The response includes an updated JSON description of the data model attributes.
{
    "id": "5f4694d651bfb7000154b5b2",
    "createdBy": "owner",
    "lastUpdatedBy": "owner@account.com",
    "creationDate": 1601831320,
    "lastUpdateDate": 1601831320,
    "name": "my-campaign-resolution-created-via-api",
    "label": "Improve product catalog data quality (created via API)",
    "description": "Increase the level of data quality for each product catalog.",
    "owners": [
        "owner@account.com"
    ],
    "ownersDetail": [
        {
            "firstName": "FIRSTNAME",
            "lastName": "LASTNAME",
            "username": "owner@account.com",
            "enabled": true,
            "preferredLanguage": "en",
            "email": "owner@account.com",
            "id": "6be3b335-05c9-4a3b-92d6-c5821f398bac"
        }
    ],
    "status": "STARTED",
    "startDate": 1598461142854,
    "endDate": null,
    "taskType": "RESOLUTION",
    "schemaRef": {
        "namespace": "org.talend.schema",
        "name": "demo_product",
        "version": 1,
        "displayName": "Demo - Product"
    },
    "impactAnalysisStatus": null,
    "fieldsAccess": null,
    "taskResolutionDelay": {
        "value": 10,
        "unit": "DAYS"
    },
    "workflow": {
        "id": null,
        "createdBy": "6be3b335-05c9-4a3b-92d6-c5821f398bac",
        "lastUpdatedBy": "6be3b335-05c9-4a3b-92d6-c5821f398bac",
        "creationDate": 1598461142855,
        "lastUpdateDate": 1598461142855,
        "tenantId": null,
        "name": "default workflow",
        "states": [
            {
                "name": "New",
                "label": "New",
                "transitionQuestion": null,
                "transitions": [
                    {
                        "name": "To validate",
                        "label": "To validate",
                        "targetStateName": "To validate",
                        "allowedRoles": [
                            "Supervisor"
                        ]
                    }
                ],
                "allowedRoles": [],
                "translations": {}
            },
            {
                "name": "To validate",
                "label": "To validate",
                "transitionQuestion": null,
                "transitions": [
                    {
                        "name": "Accept",
                        "label": "Accept",
                        "targetStateName": "Resolved",
                        "allowedRoles": [
                            "Validator"
                        ]
                    },
                    {
                        "name": "Reject",
                        "label": "Reject",
                        "targetStateName": "New",
                        "allowedRoles": [
                            "Validator"
                        ]
                    }
                ],
                "allowedRoles": [],
                "translations": {}
            },
            {
                "name": "Resolved",
                "label": "Resolved",
                "transitionQuestion": null,
                "transitions": [],
                "allowedRoles": [
                    "Validator"
                ],
                "translations": {}
            }
        ]
    }
}

If you want to edit the campaign, note the first id value from the response.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!