Adds text to a document.
This endpoint consumes up to one (1) generation each time it is called, depending on how many tools the template calls.
Call /api/generations or visit the API Dashboard to see how many generation credits you have.
Pass your API Key as a Bearer Token.
This endpoint has no request query parameters.
The request body for this endpoint is a JSON payload with the following keys:
Key | Description | Type | Example |
---|---|---|---|
command | Command to execute, see Document Commands for a list of commandsrequired | String | "[Billy's parents spoke with him and told him never to leave the house without permission again. | storyteller]" |
before | Text to prepend before the command. Defaults to being blank. | String | "Billy felt really bad about running away from home." |
after | Text to append after the command. Defaults to being blank. | String | "Billy finally learned his lesson." |
webhook_url | URL of Webhook, POST request is sent after text is generated | String | "https://a-cool-webhook.com" |
language | Object containing id and formality of language your want your copy to be in. Defaults to English if left empty. | Object | |
language.id | ID of language, see /api/languages Defaults to English if left empty. | String | "deepl_PT-BR" |
language.formality | Formalness of text, only works with select languages and DeepL. Acceptable values are "more", "less", or "default". | String | "more" |
Here's an example of the body parameters represented as a JSON object.
{
"before": "Billy felt really bad about running away from home.",
"command": "[Billy's parents spoke with him and told him never to leave the house without permission again. | storyteller]",
"after": "Billy finally learned his lesson.",
"webhook_url": "https://a-cool-webhook.com",
"language": {
"id": "deepl_PT-BR",
"formality": "more"
}
}
Command Line (curl)
curl -X POST "https://nichesss.com/api/documents/<DOCUMENT_ID>/append" -H "Content-type: application/json" -H "Authorization: Bearer <YOUR_API_KEY>" -d "{\"before\":\"Billy felt really bad about running away from home.\",\"command\":\"[Billy's parents spoke with him and told him never to leave the house without permission again. | storyteller]\",\"after\":\"Billy finally learned his lesson.\",\"webhook_url\":\"https://a-cool-webhook.com\",\"language\":{\"id\":\"deepl_PT-BR\",\"formality\":\"more\"}}"
JavaScript
fetch('https://nichesss.com/api/documents/<DOCUMENT_ID>/append', {
method: 'POST',
headers: {
'Content-type': 'application/json',
'Authorization': 'Bearer <YOUR_API_KEY>',
},
body: JSON.stringify({"before":"Billy felt really bad about running away from home.","command":"[Billy's parents spoke with him and told him never to leave the house without permission again. | storyteller]","after":"Billy finally learned his lesson.","webhook_url":"https://a-cool-webhook.com","language":{"id":"deepl_PT-BR","formality":"more"}})
})
.then((response) => response.json())
.then((data) => console.log(data));
Python
import requests
url = 'https://nichesss.com/api/documents/<DOCUMENT_ID>/append'
payload = {"before":"Billy felt really bad about running away from home.","command":"[Billy's parents spoke with him and told him never to leave the house without permission again. | storyteller]","after":"Billy finally learned his lesson.","webhook_url":"https://a-cool-webhook.com","language":{"id":"deepl_PT-BR","formality":"more"}}
headers = {'Content-type': 'application/json', 'Authorization': 'Bearer <YOUR_API_KEY>'}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(data)
PHP
$api_key = '<YOUR_API_KEY>';
$request_url = 'https://nichesss.com/api/documents/<DOCUMENT_ID>/append';
$request_options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/json' . "\r\n" .
'Authorization: Bearer ' . $api_key . "\r\n",
'content' => '{"before":"Billy felt really bad about running away from home.","command":"[Billy's parents spoke with him and told him never to leave the house without permission again. | storyteller]","after":"Billy finally learned his lesson.","webhook_url":"https://a-cool-webhook.com","language":{"id":"deepl_PT-BR","formality":"more"}}'
)
);
$request_context = stream_context_create($request_options);
$request_result = file_get_contents($request_url, false, $request_context);
$data = json_decode($request_result);
echo $data;
Ruby
require 'net/http'
require 'json'
uri = URI('https://nichesss.com/api/documents/<DOCUMENT_ID>/append')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
request['Content-type'] = 'application/json'
request['Authorization'] = 'Bearer <YOUR_API_KEY>'
request.body = {"before":"Billy felt really bad about running away from home.","command":"[Billy's parents spoke with him and told him never to leave the house without permission again. | storyteller]","after":"Billy finally learned his lesson.","webhook_url":"https://a-cool-webhook.com","language":{"id":"deepl_PT-BR","formality":"more"}}.to_json
response = http.request(request)
puts JSON.parse(response.body)
All responses from the API are JSON
{
"success": true,
"message": "Processing your document additions now.",
"queue_uri": "https://nichesss.com/api/documents/queue/XCyd7dGnBgN7aBVsUblpQ1RHL?api_key=hZ63QBPgGeRPtswNW8E3ZbaqD",
"queue_id": "XCyd7dGnBgN7aBVsUblpQ1RHL"
}