Before Unspar can publish an article, it needs to know where to send it. That destination is called an outlet. You set it up once with the address and login details Unspar needs, then publish articles to it by ID using POST /articles/{article}/publish.
Outlets are shared across your whole team, so your token needs access to all projects to create or change them. You can also see them under Outlets in the web app.
Create an outlet
To create an outlet with POST /outlets, send a name, a type, and two objects:
connection holds non-secret settings, such as the site address.
credentials holds secret values, such as a password or token.
Unspar encrypts your credentials before storing them and never returns them in API responses. Here is an example that connects a WordPress site:
curl -X POST https://app.unspar.com/api/v1/outlets \
-H "Authorization: Bearer $UNSPAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My blog",
"type": "wordpress",
"connection": { "api_url": "https://example.com/wp-json" },
"credentials": {
"username": "editor",
"password": "abcd efgh ijkl mnop qrst uvwx"
}
}'
Each type requires different fields. The linked guides show where to find each value on your site.
type |
connection |
credentials |
Guide |
wordpress |
api_url: the address of the site’s REST API, usually ending in /wp-json. |
username: a WordPress user. password: an application password for that user (rather than their regular login password). |
WordPress |
ghost |
api_url: the address of the site. |
api_key: an Admin API key from a custom integration in Ghost. |
Outlets and publishing |
github |
owner and repo: the repository. branch: an existing branch. directory: the folder where files go (leave it out to use the root folder). |
api_key: a fine-grained token with read and write access to the repository’s contents. |
GitHub |
webhook |
api_url: a public HTTPS address. |
api_key: a signing secret that your receiver also knows. |
Webhooks |
Email outlets are easiest to set up under Outlets in the web app, where you can see all their options. You can’t add new Medium outlets, though existing ones keep working.
Keep secrets out of your files
Avoid committing files with credentials to your repository. If you create outlets with the CLI, pass --secret-field to hide secret values in the command output. They appear as [REDACTED] in previews and error messages:
unspar api post /outlets --body-file github-outlet.json --secret-field api_key
Test an outlet
GET /outlets returns your outlets without their secrets. The ready field tells you whether an outlet has all the required settings, and readiness_reason explains what is missing. Neither confirms that the connection still works, so you need to run a test for that.
POST /outlets/{outlet}/test tests the connection and saves the result. What it checks depends on the outlet type:
| Outlet |
What the test does |
| WordPress |
Logs in and reads posts. |
| GitHub |
Reads the repository and the branch. |
| Webhook |
Checks the address and confirms a secret is stored, without sending anything to your receiver. |
| Email |
Sends a test email. |
You can check the outcome of the most recent test in the outlet’s last_connection_test field.
Change or delete an outlet
PATCH /outlets/{outlet} updates only the fields you include. If you omit credentials, your stored secrets stay as they are. To remove a stored secret, list it in clear_credentials:
{ "clear_credentials": { "api_key": true } }
DELETE /outlets/{outlet} removes the outlet. Unspar blocks the deletion if articles still point to the outlet or if a Project Auto publishes to it, and the response tells you what is in the way. Any projects that used the outlet as their default lose that setting, and the response lists them in cleared_project_defaults.
Find out what a site runs
POST /outlets/detect takes a site’s address in input, checks whether the site runs WordPress or Ghost, and suggests the API address to use. It doesn’t save anything. The web app runs this same check on the Assistant tab when you add an outlet.
For details on what each kind of outlet receives when you publish, see Outlets and publishing.
Endpoint reference
Generated from the OpenAPI document. Paths are relative to https://app.unspar.com.
GET/api/v1/outlets
List publishing outlets without credentials.
Operation listOutlets. Permission: unspar:outlets:read
| Parameter | In | Type | Description |
|---|
page | query | integer | Minimum 1. |
per_page | query | integer | Minimum 1. Maximum 100. |
q | query | string | |
provider_type | query | "wordpress", "medium", "ghost", "email", "github", "webhook" | |
ready | query | boolean | |
default_for_project | query | string | |
sort | query | "created_at", "-created_at", "name", "-name" | |
200 Publishing outlet list.
POST/api/v1/outlets
Create a publishing outlet. Credentials are write-only.
Operation createOutlet. Permission: unspar:outlets:write
| Body field | Type | Description |
|---|
name | string | |
type | "wordpress", "medium", "ghost", "email", "github", "webhook" | |
connection | object | |
credentials | object | |
selection | object | |
defaults | object | |
clear_credentials | object | |
POST/api/v1/outlets/detect
Detect a publishing provider from a public URL without saving it.
Operation detectOutlet. Permission: unspar:outlets:write
| Body field | Type | Description |
|---|
inputrequired | string | |
200 Outlet provider detection result.
GET/api/v1/outlets/{outlet}
Show one publishing outlet without credentials.
Operation getOutlet. Permission: unspar:outlets:read
| Parameter | In | Type | Description |
|---|
outletrequired | path | string | |
PATCH/api/v1/outlets/{outlet}
Update a publishing outlet. Omitted credentials are preserved.
Operation updateOutlet. Permission: unspar:outlets:write
| Parameter | In | Type | Description |
|---|
outletrequired | path | string | |
| Body field | Type | Description |
|---|
name | string | |
type | "wordpress", "medium", "ghost", "email", "github", "webhook" | |
connection | object | |
credentials | object | |
selection | object | |
defaults | object | |
clear_credentials | object | |
DELETE/api/v1/outlets/{outlet}
Delete a publishing outlet when article and Project Auto safeguards allow it.
Operation deleteOutlet. Permission: unspar:outlets:write
| Parameter | In | Type | Description |
|---|
outletrequired | path | string | |
200 Outlet deletion result.
POST/api/v1/outlets/{outlet}/test
Run and persist a sanitized connection test for an outlet.
Operation testOutlet. Permission: unspar:outlets:write
| Parameter | In | Type | Description |
|---|
outletrequired | path | string | |
200 Outlet connection test result.