エンドポイント
アプリを公開する
保存したアプリを、Publishボタンと同じ方法でオンラインに公開します。
POST
https://www.setherion.com/api/v1/projects/{id}/publishプラン: すべてのプラン
保存されている状態のまま、エディターのPublishボタンと同じ手順でアプリをオンラインに公開します。以前に公開したことのあるアプリはアドレスがそのまま保たれ、初めて公開するアプリには、その名前から作られた、setherion.app上のアドレスが付きます。
公開にクレジットは使いません。アプリを編集できる権限が必要です。APIでの公開は、1アカウントにつき1日100回までに制限されています。手作業で使う限り、この回数に届くことはありません。エディターのボタンには、このような制限はありません。
リクエスト
ボディは不要です。
bash
curl -X POST https://www.setherion.com/api/v1/projects/7c1e4a52-9b0d-4f3e-8a61-2d5f0c9e7b14/publish \
-H "Authorization: Bearer $SETHERION_API_KEY"レスポンス
json
{ "ok": true, "url": "https://coffee-shop.setherion.app", "ready": true }| フィールド | 型 | 意味 |
|---|---|---|
ok | boolean | アプリを公開できたときはtrueです。 |
url | string | アプリがオンラインになる場所です。 |
ready | boolean | アドレスの準備がまだ続いているときはfalseです。1、2分で使えるようになります。 |
同じ保存済みのアプリを2回公開しても問題ありません。2回目の呼び出しも、同じアドレスを返します。
編集してから公開する
公開されるのは保存されているものであり、編集は終わった時点で保存されます。そのため、編集のあとに公開を行うと、変更がオンラインになります。
js
const base = 'https://www.setherion.com/api/v1/projects'
const headers = {
Authorization: `Bearer ${process.env.SETHERION_API_KEY}`,
'Content-Type': 'application/json',
}
const edit = await fetch(`${base}/${appId}/edit`, {
method: 'POST',
headers,
body: JSON.stringify({ prompt: 'Add a contact form' }),
}).then(r => r.json())
if (edit.ok) {
const live = await fetch(`${base}/${appId}/publish`, { method: 'POST', headers }).then(r => r.json())
console.log(live.url)
}エラー
| ステータス | 発生する場合 |
|---|---|
400 | アプリのコードにAPIキーなどのシークレットが含まれていたため、公開されませんでした。エラーには、その場所が示されます。 |
401 | キーがない、間違っている、または取り消されています。 |
404 | そのアプリが存在しないか、お使いのキーでは編集できません。 |
409 | アプリにまだコードがない、必要なアドレスが使えない、または、独自のドメインに公開できない非公開アプリです。どれに当たるかは、エラーに書かれます。 |
429 | 本日、APIで100回公開しました。回数は翌日にリセットされます。 |
502 | こちら側で公開に失敗したか、ホスト上のビルドに失敗しました。もう一度お試しください。 |
503 | 公開が一時的に利用できません。1分後にもう一度お試しください。 |
エラー文の原文
| ステータス | error |
|---|---|
400 | Publishing would put a secret key on the open internet: ... に続いて、シークレットの種類、ファイルと行、代わりにすべきことが入ります。 |
404 | No such app on this account. |
409 | This app has no code yet. Build it in Setherion first. |
409 | The address coffee-shop.setherion.app belongs to another app. Choose a different one. |
409 | Could not find a free address for this app. Rename it and publish again. |
409 | This app is private, and a private app can only be published on its setherion.app address. To use a domain of your own, make it public first. Otherwise try again in a moment. Nothing was published. |
429 | That is 100 publishes through the API today. The count resets tomorrow. |
502 | The build failed on the host, so this version is not online. Publish again, and if it fails again, ask for a fix in the editor. |
502 | The build was cancelled on the host, so this version is not online. Publish again. |
503 | Publishing is briefly unavailable. Try again in a minute. |
このページは役に立ちましたか?
