ログイン POST
メールアドレスとパスワードで認証し、JWT トークンを取得します。
エンドポイント
POST https://api.pocketalert.app/v1/auth/signinリクエスト
ヘッダー
| ヘッダー | 必須 | 説明 |
|---|---|---|
Content-Type | ✅ | application/json |
ボディパラメーター
| パラメーター | 型 | 必須 | 説明 |
|---|---|---|---|
email | string | ✅ | 登録済みのメールアドレス |
password | string | ✅ | アカウントのパスワード |
リクエスト例
bash
curl -X POST "https://api.pocketalert.app/v1/auth/signin" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "your-password"
}'javascript
const response = await fetch('https://api.pocketalert.app/v1/auth/signin', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: '[email protected]',
password: 'your-password'
})
});
const { token } = await response.json();
// Use token in Authorization header for subsequent requestspython
import requests
response = requests.post(
'https://api.pocketalert.app/v1/auth/signin',
json={
'email': '[email protected]',
'password': 'your-password'
}
)
data = response.json()
# Use token in Authorization header for subsequent requestsphp
$response = Http::post('https://api.pocketalert.app/v1/auth/signin', [
'email' => '[email protected]',
'password' => 'your-password',
]);
$token = $response->json()['token'];
// Use token in Authorization header for subsequent requestsレスポンス
成功時のレスポンス
200 OK
認証に成功しました
| フィールド | 型 | 説明 |
|---|---|---|
token | string | API 認証に使用する JWT トークン |
email | string | ユーザーのメールアドレス |
name | string | ユーザーの表示名 |
avatar | string | ユーザーのアバター画像の URL |
json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"email": "[email protected]",
"name": "John Doe",
"avatar": ""
}トークンの使用方法
トークンを取得したら、以降のリクエストに含めてください。
bash
curl -X GET "https://api.pocketalert.app/v1/messages" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."エラーレスポンス
| ステータス | 説明 |
|---|---|
400 | 不正なリクエスト — メールアドレスまたはパスワードが未入力、もしくは captcha の検証に失敗 |
401 | 認証情報が無効 — パスワードが間違っている、または未登録のメールアドレス |
推奨
サーバー側の連携には、JWT トークンの代わりに API キーの利用をおすすめします。API キーには有効期限がなく、管理も簡単です。