Workforce content generation API
On this page we explain how to use the Workforce APIs to generate content using the submitContentGenerationJob mutation.
For an overview of integrating Workforce with your existing content workflow, see Workforce integration overview.
You can try out the examples below using the API playground or from within your own code.
AuthorizationLink copied!
Personal Access Tokens (PATs) are used to authorize access to the API.
For each request set the authorization format to bearer, and include the PAT in the request:
Note that you must be an organization admin in order to generate a personal access token.
API endpointLink copied!
The Workforce API is part of the GraphQL Management API. There is a single endpoint for all requests to the API:
https://api.amplience.net/graphql
Submitting a content generation jobLink copied!
The format of a content generation request is shown below. This request shows how to generate a blog with the title "A blog about hats", using British English and the GPT-4o AI model. The request also specifies brand voice, audience and tone of voice.
hubId and organizationId are mandatory.
See Example content generation request for more details of the request and how to retrieve the generated content.
Content generation uses Amplience Credits
A content generation job will use Amplience Credits. If you do not have sufficient credits to complete the job then an error will be returned. See credit usage for an example of how to get your credit balance.
Information you need to provideLink copied!
For each content generation job you will need to include:
- The organization id
- The hub id
- The brief template id
content
The content object must include the id of the AI model to be used to generate the content. It also requires the briefInputs, the fields of this object will be specific to the brief template used, should be sent as string of encoded JSON and will usually include fields such as ‘title’, ‘product name’ and ‘product features’. The specific fields for each brief template can be found in the inputSchema field of the template. See brief templates for an example query that returns this information for each template.
Copying information from Workforce
The example queries on this page show how to retrieve the information you need for a content generation request. You can also copy information such as the template id, AI model id and the fields defined in the template, from within Workforce.
Optional input fieldsLink copied!
To further refine the generated content you can also specify:
- The brand voice
- The audience
- The tone of voice
- The locale
- A list of examples
- Additional information (for those templates that include this field).
Example queries showing how to retrieve the information to send as inputs to the content generation request are shown below.
Organization idLink copied!
The organization id links to your account and ensures you have the Amplience credits you'll need to generate content.
You can find your organization by logging in to the API playground and running the following query. You will need to be an organization admin to run this request.
The organization id will be returned in the response.
Credit usageLink copied!
You can find out how many credits are remaining for your organization and the current credit allowance using the following query.
Replace id with your own organization id.
Hub idLink copied!
You will need the hub id to find other information that you can include in content generation requests, to return the brand voices or audiences that are configured on a hub, for example.
Example responseLink copied!
A partial response is shown below, showing the available hubs. This example shows the id of the "documentation" hub which we'll use in the example queries on this page. Replace this id with the id of your own hub.
Brand voicesLink copied!
Using the hub id you can list the brands set up on a hub. To list the brands on Documentation hub we use the following query, setting id to the hub id.
Replace id with the id of your own hub.
Example responseLink copied!
There are two brand voices set up on the hub and the response includes their name, label and id.
Tones of voiceLink copied!
The following query lists the tones of voice configured on the specified hub. Replace id with the id of your own hub.
Example responseLink copied!
The following response lists the tones of voice on the "Documentation" hub.
AudiencesLink copied!
The following query will return all the audiences defined for the specified hub. Replace id with the id of your own hub.
Example responseLink copied!
These are the audiences configured on "Documentation" hub.
Brief templatesLink copied!
The following query can be used to list the content generation templates that are configured on a hub, including any custom templates you created. inputSchema will return the configuration of each template.
Replace id with the id of your hub.
Example responseLink copied!
On "Documentation" hub there are the standard templates, together with some custom templates we've set up, including "Women's dresses" and "Running shoes". We've included a partial response below. inputSchema is JSON encoded.
The brief template id must be specified in the content generation request.
ModelsLink copied!
The following query will list each of the models configured on a hub. You will need to specify the model id in the content generation request.
Example responseLink copied!
The AI models available on the "Documentation" hub are shown in the response below.
Example content generation requestLink copied!
The following request uses the blog template and requests a blog about hats, using the GPT4o model and no additional parameters.
To try out this query, replace hubId with the id of your own hub and organizationId with your organization id. The other ids will be the same across all hubs.
Example responseLink copied!
The content generation response is as follows. We will use the job id to return generated content when the job is complete.
Retrieving the generated contentLink copied!
To retrieve the generated content you will need to query getContentGenerationJob with the job id.
If a status of SUBMITTED is returned, the job is still being processed. Keep querying the job until one of the following statuses is returned:
| Status | Description |
|---|---|
| COMPLETE | The content is returned in the response |
| ERROR | The status message contains more information about the error |
| INSUFFICIENT_CREDITS | You do not have enough credits to complete the request |
Info
You can set up a webhook that will be triggered when a content generation job is complete. See Workforce integration overview for more details.
Example responseLink copied!
An example of a completed job is shown below, in this case it's the content generated for the blog we requested.
Example with brand voice, audience and tone of voiceLink copied!
The following request extends the blog content generation request and includes brand voice, audience, tone of voice and locale in briefInputs. We've also included fields specific to the product description template, including maximum word count, product features and images. We've specified a brand voice of Anya Finn, an audience of luxury travellers and a tone of voice of humorous and witty to be used to generate the content.
To try out this query, replace hubId with the id of your own hub and organizationId with your organization id. The other ids will be the same across all hubs.
Example responseLink copied!
The following response shows that the job has been submitted.
Retrieving the contentLink copied!
To retrieve the content we poll getContentGenerationJob until the request is complete.
Example generated contentLink copied!
The generated content reflects the brand voice, audience and tone of voice we included in the request.
Example with image inputsLink copied!
The following example shows how to generate content using the product description template and includes images as part of the inputs to the request. The request defines input using a GraphQL variable.
For each image included in a request you need to specify an id, in this example a random UUID, and the image URL. The id is not validated so you can use any unique value. The URL must be an Amplience domain, either a Content Hub URL, or uploaded using the temporary file service.
To try out this query, replace hubId with the id of your own hub and organizationId with your organization id. The other ids will be the same across all hubs.
Add the following to the variables section of the request. We have specified 3 images to be used as part of the content generation request.
Example responseLink copied!
The content generation job id is returned in the response.
We use this id to poll getContentGenerationJob until the job is complete.
And here's an example of the generated product description content.
Submitting multiple content generation jobsLink copied!
You can submit up to 5 content generation jobs as part of one request as shown below.
For this example include input1 and input2 in the variables section of the request.
Replace organizationId and hubId with your own organization id and the id of the hub you're using.
Retrieving multiple content generation jobsLink copied!
To retrieve the content generation response, call getContentGenerationJobs until each request is complete.
Include the following in the variables section of the request.
The generated content is returned in the response. In this case the 2 blog posts we requested.
Custom templatesLink copied!
You can generate content using your custom templates in the same way as the standard templates available on each hub:
- Find the template id by querying the templates on your hub
- Submit a content generation request, specifying values for the fields you've defined for your template
- Poll for the response
Custom templates have an "additional instructions" section that should include a detailed prompt specifying how content should be generated. You do not need to specify this in the content generation request, it will be read from the template and sent as part of each request. Note that you can't currently specify brand voice, audience or tone of voice, so this will need to be included as guidance to the model in the "additional instructions" section of the template.
The following example shows how to generate content from the "Running shoe" custom template. This has a template id of Q29udGVudEdlbmVyYXRpb25CcmllZlRlbXBsYXRlOjEyZjNkNWFiLTliMmUtNDg2Ny05Y2YyLThhZTdiNDliNzk4OA==.
We have just specified the title. The instructions are taken from the template and used with each content generation.
To send a request using your own custom template, replace briefTemplateId with the id of your own template, organizationId with your own organization id and hubId with the id of your own hub.
Example responseLink copied!
As with other content generation requests, the response to SubmitContentGenerationJob will contain the id that you will use to poll for the generated content.
Retrieving the contentLink copied!
Call getContentGenerationJob with the job id until the request is complete.
Here's an example of a completed job, with content generated from our custom template and using the "additional instructions" defined in the custom template.
Retrieving custom template input fieldsLink copied!
The following query shows how to get the name and label for the input fields configured in a template, in this case the "Running shoe" custom template. Change the id to the id of the template that you want to return.
Example responseLink copied!
The fields defined for the "Running shoes" template are shown below, together with the full template configuration.
Related pagesLink copied!
GraphQL Management API- limits