Endpoints · Connect
POST/v1/connect
The WooCommerce plugin swaps the approved code for its key.
What it does
The second half of the WooCommerce plugin's Connect: the shop's server swaps the one-time code its owner approved for the shop's key and webhook secret, once, within ten minutes, for that site only. Your own site does not need this: make the key in the portal.
No key: the one-time code is the credential. Any method but POST answers 405 method_not_allowed: “POST only.”
curl -X POST "https://printwisp.com/v1/connect" \
-H "Content-Type: application/json" \
-d '{"code":"0f3a9c1e5b7d2f4a6c8e0b2d4f6a8c1e3b5d7f9a2c4e6b8d","site":"https://harbourprints.com.au"}'
# 200
{
"ok": true,
"key": "sk_live_…",
"keys": { "test": "sk_test_…", "live": "sk_live_…" },
"webhook_secret": "whsec_…",
"studio_url": "https://printwisp.com",
"integration": "int_2b7c9e0d4a1f6835",
"store": { "id": "ten_harbour", "name": "Harbour Prints", "code": "harbour-woo", "status": "draft" }
}<?php
$ch = curl_init('https://printwisp.com/v1/connect');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
'code' => '0f3a9c1e5b7d2f4a6c8e0b2d4f6a8c1e3b5d7f9a2c4e6b8d',
'site' => 'https://harbourprints.com.au'
]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$answer = json_decode(curl_exec($ch), true);// Node
const r = await fetch('https://printwisp.com/v1/connect', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
code: '0f3a9c1e5b7d2f4a6c8e0b2d4f6a8c1e3b5d7f9a2c4e6b8d',
site: 'https://harbourprints.com.au'
}),
});
const answer = await r.json();import requests
r = requests.post(
"https://printwisp.com/v1/connect",
json={
"code": "0f3a9c1e5b7d2f4a6c8e0b2d4f6a8c1e3b5d7f9a2c4e6b8d",
"site": "https://harbourprints.com.au"
},
)
answer = r.json()Parameters
| Parameter | Type | Description |
|---|---|---|
code required | string | The one-time code (48 hex) the shop's browser received after its owner approved. |
site required | string | The shop's address; must have the host the code was made for. |
shop_name | string | The shop's own name; names the store until the owner renames it. |
shop_currency | string | The shop's currency, 3 letters. |
prices_include_tax | boolean | Whether the shop's prices include tax. |
Response
200 application/json. The shop's keys and webhook secret, shown this once. key is the live key (kept for plugins made before test keys); keys holds the test and the live key. store.id is the organisation's id; store.name, store.code and store.status are the connected store's.
{
"ok": true,
"key": "sk_live_…",
"keys": { "test": "sk_test_…", "live": "sk_live_…" },
"webhook_secret": "whsec_…",
"studio_url": "https://printwisp.com",
"integration": "int_2b7c9e0d4a1f6835",
"store": { "id": "ten_harbour", "name": "Harbour Prints", "code": "harbour-woo", "status": "draft" }
}Errors
| HTTP | error | message |
|---|---|---|
| 400 | invalid_code | That connection code is not valid any more. Press Connect again. |
| 400 | invalid_code | That code was made for another site. |
| 405 | method_not_allowed | POST only. |