Перейти до вмісту
AstroWay/api v2.202.3 · docs
усі системи в нормі

Move a WordPress site onto an account key

POST
/site-keys/connect/exchange
request.sh
curl -X POST https://api.astroway.info/v1/site-keys/connect/exchange \
-H "X-Api-Key: aw_live_..." \
-H "Content-Type: application/json" \
-d '{ "code": "Jx3l0v8QeZcX2n9F1aK7pM4sT6bW5yR0uH2dG8jC1oE", "site_url": "https://example.com" }'

Second half of connecting a site to an account. The owner picks a key on api.astroway.info/dashboard/connect, which sends the admin back to the site with a one-time code; the plugin exchanges it here, server side, sending its site key in X-Api-Key. The code lives 5 minutes; the same code from the same site key within 10 minutes returns the same answer, so a plugin that crashed before saving can ask again. The site key stops working 24 hours after the exchange. Errors: 400 INVALID_CODE, 410 CODE_EXPIRED, 403 SITE_MISMATCH.

fields
string

Comma-separated dotted paths, relative to data, to keep in the response. A path is applied to every element of an array, so planets.name means the name of each planet. Paths that match nothing come back in _fields_unmatched; a list where nothing matches at all is a 400, because an empty object would be a confident wrong answer.

Example
planets.name,planets.longitude
precision
integer
<= 15

Round every non-integer number in the response to this many decimal places. Integers are left alone, because an id is not a measurement. Ecliptic longitudes ship with fourteen decimals by default; 2 is about a tenth of an arcminute.

Example
4
Media type application/json
object
code required

The one-time code the dashboard appended to the return URL.

string
>= 43 characters <= 43 characters
site_url required

The site home URL, the same one the site key was issued for.

string format: uri
Example
{
"code": "Jx3l0v8QeZcX2n9F1aK7pM4sT6bW5yR0uH2dG8jC1oE",
"site_url": "https://example.com"
}

Successful calculation

Media type application/json
object
ok
boolean
data
object
key
string
nullable
plan
string
nullable
domain
string
nullable
account
string
nullable
Example
{
"ok": true,
"data": {
"key": "aw_live_…",
"plan": "free",
"domain": "example.com",
"account": "j***@example.com"
}
}

Validation error

Media type application/json
Example
{
"ok": false,
"error": {
"code": "INVALID_INPUT",
"message": "Validation failed: date: Date must be YYYY-MM-DD",
"details": [
{
"path": "date",
"message": "Date must be YYYY-MM-DD"
}
]
}
}

Missing or invalid API key

Media type application/json
Example
{
"ok": false,
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid API key"
}
}
Корисно?