Stylograph API

Send a note

Checks the account, the card back, the cover (or a letter's design), the address and every character, then charges the format's credits and queues the note for printing. Scope: `notes:send`, and `recipients:write` for a new `recipient`. Every send needs an `Idempotency-Key`; a dry run needs none. A note whose content check flags something, or couldn't run, is held for a person at Stylograph to look at before it prints. It shows as `queued` while it waits; if it is turned down it becomes `failed` with `failure_code: content_rejected` and its credits are refunded.

POST
/api/v1/notes

Checks the account, the card back, the cover (or a letter's design), the address and every character, then charges the format's credits and queues the note for printing. Scope: notes:send, and recipients:write for a new recipient. Every send needs an Idempotency-Key; a dry run needs none. A note whose content check flags something, or couldn't run, is held for a person at Stylograph to look at before it prints. It shows as queued while it waits; if it is turned down it becomes failed with failure_code: content_rejected and its credits are refunded.

Authorization

ApiKeyAuth
headerAuthorizationBearer <API key (sg_live_...)>

An API key from Settings.

Header Parameters

Idempotency-Key?string

Required for a send (not a dry run): unique to the note, e.g. a UUID. A retry with the same key and body returns the same note and charges nothing.

Match^[!-~]{1,255}$
Length1 <= length <= 255

Request Body

application/json
  1. body

Send exactly one of recipient_id and recipient. Unknown fields are refused.

recipient_id?string

Someone in your address book. Find one with GET /api/v1/recipients.

Formatuuid
recipient?

Someone not in your address book yet (needs recipients:write). Matched to an existing entry with the same name and address, ignoring case; otherwise added once the send passes every check.

format*string

folded: a folded notecard. postcard: a 4x6 postcard. letter: one handwritten page on stationery, mailed flat in a 9x12 envelope; it needs letter_design_id, and only an account with letters on can send one (letters in GET /api/v1/account). flat: a 4x6 flat card mailed in an A6 envelope, the cover on its front and the message on its back. It takes a cta only where the organization has the flat notecard QR on (the QR prints on the front, with no verbal cue; any other key gets 400 INVALID_ARGUMENT), it takes no card back, and only an organization Stylograph has turned it on for can send one (GET /api/v1/account lists flat only then; any other key gets 400 PRODUCT_UNAVAILABLE).

Value in"folded""postcard""letter""flat"
message*string

The note's text. At most 400 characters for a folded note, 180 characters for a postcard, 2000 characters for a letter and 300 characters for a flat card, counted as printed: curly quotes, dashes and ellipses are made plain first (an ellipsis prints as three periods). A letter is also held to its design's own, smaller limit (max_chars in GET /api/v1/letter-designs), and keeps its line breaks: a blank line starts a new paragraph. A flat card's message, with its closing, must also fit the 4x6 back at a readable size in the writer's hand: one that doesn't answers 422 MESSAGE_DOES_NOT_FIT with details.over_by, about how many characters to cut.

Length1 <= length <= 2000
closing?
card_image_key?string

A key from GET /api/v1/covers, or one of your uploads. Leave it out for the default cover (default_cover_key). Every folded note, postcard and flat card has a cover. A letter takes none: sending one with a letter answers 400 INVALID_ARGUMENT.

Lengthlength <= 512
card_back_id?|

A folded note's card back: an id from GET /api/v1/card-backs, or null for none. Leave it out for the account's default back, if it has one (none on a postcard, a letter or a flat card). An id sent with a letter answers 400 INVALID_ARGUMENT.

Formatuuid
letter_design_id?|

The stationery a letter is written on: an id from GET /api/v1/letter-designs. Required for a letter. On any other format, leave it out or send null. A design the account can't use answers 422 LETTER_DESIGN_UNAVAILABLE.

Formatuuid
qr_url?|

Letters only: an https link the letter's QR code opens, at most 120 characters, with a lower-case site name and no spaces. It is stored on the note and returned as qr_url. It must start with an origin on the account's allow-list, which Stylograph support sets; a link on any other site, or on an account with no list, answers 422 QR_URL_NOT_ALLOWED, and a design with no place for the code (or for the account's footer line) answers 422 LETTER_DESIGN_NO_QR. A folded note or postcard takes its QR link in cta instead. Leave it out for no QR code. On any other format, leave it out or send null.

Lengthlength <= 120
writer_id?string

Whose handwriting the note is written in (issue #973): a writer from GET /api/v1/writers. Leave it out for the key's own member. Only an Operator's key can name a teammate; the note is still paid by the organization and recorded as sent by the key's member. Not on a letter.

Formatuuid
handwriting_profile_id?string

Optional: refuse the send if it isn't the writer's current handwriting (the key's member's, or writer_id's; GET /api/v1/writers shows it).

Formatuuid
return_address_on?boolean

Only a postcard may set false. A letter's envelope always carries a return block: the account's return lines when Stylograph has set them, otherwise its name and return address.

Defaulttrue
scheduled_for?|

Send later: the day the note goes to print, as YYYY-MM-DD. After today's date in UTC and no more than 90 days ahead. The note is queued and charged now, and the printer doesn't see it before that day. Leave it out, or send null, to print as soon as possible. Until the printer starts on it the note can be cancelled (DELETE /api/v1/notes/{noteId}) and its credits come back. The date can't be moved: cancel and send again with a new Idempotency-Key.

Formatdate
cta?|

Print a QR code on the note, to the account's referral link (type: referral) or to a link of your own on one of the account's QR code sites (type: visit, with url), with an optional line beside it. Leave it out, or send null, for no QR code. A letter takes none (it has qr_url; sending one answers 400 INVALID_ARGUMENT). A flat card takes one only where the organization has the flat notecard QR on: the code prints on the front with no verbal_cue, and any other organization gets 400 INVALID_ARGUMENT.

client?string

Optional: a short label for the app sending the note, e.g. zapier. It is kept on the note and returned as client, and changes nothing about the send: no price, limit or check reads it. It is left out of the request an Idempotency-Key is matched against.

Match^[a-z0-9][a-z0-9._-]{0,39}$
Length1 <= length <= 40
idempotency_key?string

Only for a client that cannot set the Idempotency-Key header; when both are sent they must match.

Match^[!-~]{1,255}$
Length1 <= length <= 255
dry_run?boolean
Defaultfalse
crm_contact?|

Optional: the person in your CRM the note is for. A team mails at most one note a day (the UTC day it goes to print: scheduled_for, else the day it is sent) to a CRM contact, whichever app or integration sends it, so a Zap and a CRM connector firing on one event mail one card. A second is refused with 409 DUPLICATE_NOTE (details.reason same_crm_contact_day) unless allow_duplicate is set. Sends without it are never merged by name or address, so siblings at one address all get their own note.

allow_duplicate?boolean

Send even though this recipient was sent this same message in the last 24 hours, or this crm_contact already has a note going to print that day. Without it, such a send is refused with DUPLICATE_NOTE and nothing is charged. It doesn't change what an Idempotency-Key replays.

Defaultfalse

Response Body

A dry run (what the send would do), or a retry of a send with the same key (Idempotent-Replayed: true).

application/json
  1. response
data*
Example Request
curl -X POST 'https://composer.stylograph.ai/api/v1/notes' \  -H 'Content-Type: application/json' \  -d '{  "format": "folded",  "message": "string"}'
Example Response
{  "data": {    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",    "reference": "string",    "status": "queued",    "format": "folded",    "source": "api",    "client": "string",    "recipient": {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "first_name": "string",      "last_name": "string"    },    "content_purged": true,    "content_purged_at": "2019-08-24T14:15:22Z",    "failure_code": "string",    "refund": {      "credits": 1,      "refunded_at": "2019-08-24T14:15:22Z"    },    "card_back": {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "name": "string"    },    "letter_design": {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "name": "string"    },    "qr_url": "string",    "stylograph_back": true,    "scheduled_for": "2019-08-24",    "cta": {      "type": "referral",      "verbal_cue": "string",      "qr": true,      "scans": 0    },    "created_at": "2019-08-24T14:15:22Z",    "updated_at": "2019-08-24T14:15:22Z"  }}