copyfactory.io
  • Getting started
    • Overview
      • Authentication
      • Rate limiting
      • Errors
  • API
    • Playbooks
      • The playbook object
      • List playbooks
    • Sequences
      • The sequence object
      • List sequences
    • Contacts
      • The contact object
      • Create contact
      • Get contact
      • Search contacts
    • Profiles
      • The profile object
      • Get a profile
      • List all profiles
    • Premises
      • The premise object
      • Get a premise
      • List all premises
    • Generations
      • The generations object
      • Generate text
  • Text Generation Tutorials
    • How to generate text
  • App
    • Website
    • Login
Powered by GitBook
On this page
  1. API
  2. Generations

Generate text

PreviousThe generations objectNextHow to generate text

Last updated 2 years ago

To generate text you need a and a dictionary containing keys that are the the required fields for the premise fields and values that contain the actual data.

Here is a basic example for a sentence premise where the required datapoints would have been [' first_name', 'person_description'].

{
	"first_name": "Mark",
	"person_description": "This is my description of someone..."
}

If you do not know the required fields for your premise ID use the .

If you receive an empty sentence back this is likely due to an error in your variables. Make sure to check the required fields and try again. All generations will contain meta data on the request.

Generate text for personalizing contacts or for generating entire emails.

POST https://app.copyfactory.io/api/v2/generate/

Headers

Name
Type
Description

Authorization*

string

Your Copyfactory API key

Request Body

Name
Type
Description

premise_id*

int

The ID of the sentence premise you wish to use.

variables*

object

A dictionary with keys containing the required data fields and values which contain the actual contact data.

{
	"status": "success",
	"content": "This is the generated sentence based on the prospect data.",
	"meta_data": {
		"sentence_premise": {
			"id": 20,
			"order": 1,
			"is_active": False,
			"required_variables": ["first_name", "company_description"],
			"sentence_premise_name": "Company - Edited",
			"profile_name": "Copyfactory"
		},
		"variables": {
			"first_name": "Mark",
			"company_description": "This is my company description"
		}
	}
}
curl --location --request POST 'https://app.copyfactory.io/api/v2/generate/' \
--header 'Authorization: API-KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
            "premise_id": PREMISE_ID,
            "variables": {"field_name":"field data"}
}'
import requests
import json

url = "https://app.copyfactory.io/api/v2/generate/"

payload = json.dumps({
  "premise_id": PREMISE_ID,
  "variables": {
    "field_name": "field data"
  }
})

headers = {
  'Authorization': 'API-KEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
premise ID
get premise endpoint