Documents
Generate content from a template and fetch the result.
Generate a document
api.app.typetone.ai/public/v1/document Generates content from a template. input is a JSON string with the fields the template asks for; get them from the template endpoints.
Authorization
X-API-KeyheaderrequiredYour workspace API key.
Request body
templateIdstringrequiredID of the template, from List templates.
language_keystringrequiredLanguage to write in, for example
ENorNL.One of
NLENESITGRSEPTFRFIPLDETRDKRUNOinputstringrequiredThe input passed to the template parameters. Which fields should be added depends per template, and can be queried from the
/templateendpointtoneOfVoiceMetaIdstring | nullOptional tone of voice to write in, from the tone of voice endpoints.
Response · 201
messagestringrequiredStatus message.
documentIdstringrequiredID of the generated document. Fetch it with Get a document.
Errors
-
401Missing or invalid API key. -
403The workspace is not on a plan with API access. -
404The resource does not exist in this workspace. -
422A parameter or the request body is invalid.detailsays which.
curl -X POST "https://api.app.typetone.ai/public/v1/document" \
-H "X-API-Key: $TYPETONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateId": "cmuf2k8x10001ab12cd34ef56",
"language_key": "NL",
"input": "{\"text\":\"The benefits of AI in software development\",\"tone\":\"Professional yet approachable\"}",
"toneOfVoiceMetaId": "cmuf2k8x10001ab12cd34ef56"
}' import os
import requests
response = requests.post(
"https://api.app.typetone.ai/public/v1/document",
headers={"X-API-Key": os.environ["TYPETONE_API_KEY"]},
json={
"templateId": "cmuf2k8x10001ab12cd34ef56",
"language_key": "NL",
"input": "{\"text\":\"The benefits of AI in software development\",\"tone\":\"Professional yet approachable\"}",
"toneOfVoiceMetaId": "cmuf2k8x10001ab12cd34ef56"
},
)
response.raise_for_status()
print(response.json()) const response = await fetch("https://api.app.typetone.ai/public/v1/document", {
method: "POST",
headers: {
"X-API-Key": process.env.TYPETONE_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"templateId": "cmuf2k8x10001ab12cd34ef56",
"language_key": "NL",
"input": "{\"text\":\"The benefits of AI in software development\",\"tone\":\"Professional yet approachable\"}",
"toneOfVoiceMetaId": "cmuf2k8x10001ab12cd34ef56"
}),
});
const data = await response.json(); {
"message": "string",
"documentId": "cmuf2k8x10001ab12cd34ef56"
} Get a document
api.app.typetone.ai/public/v1/document/{id} Authorization
X-API-KeyheaderrequiredYour workspace API key.
Path parameters
idstringrequiredUnique ID.
Response · 200
idstringrequiredUnique ID.
titlestringrequiredsharedbooleanrequireddocumentarray of object | nullrawDocumentstringrequiredgeneratedOutputstringrequiredbulkInputIdstring | nulllanguageKeystring | nullOne of
NLENESITGRSEPTFRFIPLDETRDKRUNOtemplateIdstring | nullID of the template, from List templates.
toneOfVoiceIdstring | null
Errors
-
401Missing or invalid API key. -
403The workspace is not on a plan with API access. -
404The resource does not exist in this workspace. -
422A parameter or the request body is invalid.detailsays which.
curl "https://api.app.typetone.ai/public/v1/document/cmuf2k8x10001ab12cd34ef56" \
-H "X-API-Key: $TYPETONE_API_KEY" import os
import requests
response = requests.get(
"https://api.app.typetone.ai/public/v1/document/cmuf2k8x10001ab12cd34ef56",
headers={"X-API-Key": os.environ["TYPETONE_API_KEY"]},
)
response.raise_for_status()
print(response.json()) const response = await fetch("https://api.app.typetone.ai/public/v1/document/cmuf2k8x10001ab12cd34ef56", {
headers: {
"X-API-Key": process.env.TYPETONE_API_KEY,
},
});
const data = await response.json(); {
"id": "cmuf2k8x10001ab12cd34ef56",
"title": "string",
"shared": true,
"document": [
{}
],
"rawDocument": "string",
"generatedOutput": "string",
"bulkInputId": "cmuf2k8x10001ab12cd34ef56",
"languageKey": "NL",
"templateId": "cmuf2k8x10001ab12cd34ef56",
"toneOfVoiceId": "cmuf2k8x10001ab12cd34ef56"
} Something unclear or missing? Tell us and we'll improve this page.