バッチ単一プッシュAPI

機能説明

バッチ単一プッシュ通知に使用され、1回の呼び出しで複数の対象ユーザーにプッシュを送信できます。registration_idまたはaliasを介したプッシュに対応しています:

  • registration_idによるプッシュPOST /v4/batch/push/regid
  • aliasによるプッシュPOST /v4/batch/push/alias
  • 機能制限
    • 1リクエストあたりの最大プッシュ対象数は500です
    • 効率化のため並行処理をサポート
    • レート制限時に部分的な成功結果を返却
    • 本APIはプッシュAPIとQPSクォータを共有します。バッチプッシュAPIを使用して1つのregidまたは1つのaliasにプッシュすると、プッシュAPIのQPSクォータを1消費します。

認証

HTTPヘッダーに認証フィールドを追加します:

Authorization: Basic ${base64_auth_string}
              
              Authorization: Basic ${base64_auth_string}  

            
このコードブロックはフローティングウィンドウ内に表示されます
  • 生成方法base64(username:password)
    • username = アプリケーションのAppKey
    • password = Master Secret
  • アクセスパス:コンソール → アプリケーション設定アプリケーション情報

エンドポイント

  • registration_idによるバッチプッシュ
POST /v4/batch/push/regid
              
              POST /v4/batch/push/regid

            
このコードブロックはフローティングウィンドウ内に表示されます
  • aliasによるバッチプッシュ
POST /v4/batch/push/alias
              
              POST /v4/batch/push/alias

            
このコードブロックはフローティングウィンドウ内に表示されます

リクエスト例

1. registration_idによるバッチプッシュ

curl --insecure -X POST -v https://webpushapi-sgp.engagelab.com/v4/batch/push/regid \ -H "Content-Type: application/json" \ -u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12" \ -d '{ "requests": [ { "target": "registration_id_1", "platform": "web", "notification": { "alert": "Hi,Push !", "web": { "alert": "Hi,Push !", "title": "web_push", "url": "http://www.google.com", "extras": { "web-key1": "web-value1" } } }, "options": { "time_to_live": 60, "apns_production": false }, "custom_args": { "business": "info" } }, { "target": "registration_id_2", "platform": "web", "notification": { "alert": "Hi,MTPush !", "web": { "alert": "Hi,MTPush !", "title": "web_push", "url": "http://www.google.com", "extras": { "web-key1": "web-value1" } } }, "options": { "time_to_live": 60, "apns_production": false } } ] }'
              
              curl --insecure -X POST -v https://webpushapi-sgp.engagelab.com/v4/batch/push/regid \
  -H "Content-Type: application/json" \
  -u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12" \
  -d '{
    "requests": [
      {
        "target": "registration_id_1",
        "platform": "web",
        "notification": {
            "alert": "Hi,Push !",
            "web": {
                "alert": "Hi,Push !",
                "title": "web_push",
                "url": "http://www.google.com",
                "extras": {
                    "web-key1": "web-value1"
                }
            }
        },
        "options": {
          "time_to_live": 60,
          "apns_production": false
        },
        "custom_args": {
          "business": "info"
        }
      },
      {
        "target": "registration_id_2",
        "platform": "web",
        "notification": {
            "alert": "Hi,MTPush !",
            "web": {
                "alert": "Hi,MTPush !",
                "title": "web_push",
                "url": "http://www.google.com",
                "extras": {
                    "web-key1": "web-value1"
                }
            }
        },
        "options": {
          "time_to_live": 60,
          "apns_production": false
        }
      }
    ]
  }'

            
このコードブロックはフローティングウィンドウ内に表示されます

2. aliasによるバッチプッシュ

curl --insecure -X POST -v https://webpushapi-sgp.engagelab.com/v4/batch/push/alias \ -H "Content-Type: application/json" \ -u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12" \ -d '{ "requests": [ { "target": "user_alias_1", "platform": "web", "notification": { "alert": "Hi,Push !", "web": { "alert": "Hi,Push !", "title": "web_push", "url": "http://www.google.com", "extras": { "web-key1": "web-value1" } } }, "options": { "time_to_live": 60, "apns_production": false } }, { "target": "user_alias_2", "platform": "web", "notification": { "alert": "Hi,MTPush !", "web": { "alert": "Hi,MTPush !", "title": "web_push", "url": "http://www.google.com", "extras": { "web-key1": "web-value1" } } }, "options": { "time_to_live": 60, "apns_production": false } } ] }'
              
              curl --insecure -X POST -v https://webpushapi-sgp.engagelab.com/v4/batch/push/alias \
  -H "Content-Type: application/json" \
  -u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12" \
  -d '{
    "requests": [
      {
        "target": "user_alias_1",
        "platform": "web",
        "notification": {
            "alert": "Hi,Push !",
            "web": {
              "alert": "Hi,Push !",
                "title": "web_push",
                "url": "http://www.google.com",
                "extras": {
                    "web-key1": "web-value1"
                }
            }
        },
        "options": {
          "time_to_live": 60,
          "apns_production": false
        }
      },
      {
        "target": "user_alias_2",
        "platform": "web",
        "notification": {
            "alert": "Hi,MTPush !",
            "web": {
              "alert": "Hi,MTPush !",
                "title": "web_push",
                "url": "http://www.google.com",
                "extras": {
                    "web-key1": "web-value1"
                }
            }
        },
        "options": {
          "time_to_live": 60,
          "apns_production": false
        }
      }
    ]
  }'


            
このコードブロックはフローティングウィンドウ内に表示されます

リクエストパラメータ

リクエストボディ構造

{ "requests": [ { "target": "string", // 必須、プッシュ対象(registration_idまたはalias) "platform": "string", // 必須、プッシュプラットフォーム設定(プッシュAPIを参照) "notification": "object", // オプション、通知コンテンツ(プッシュAPIを参照) "message": "object", // オプション、カスタムメッセージ(プッシュAPIを参照)、notificationと同時に存在できません "options": "object", // オプション、プッシュオプション(プッシュAPIを参照) "custom_args": "object" // オプション、クライアントに渡されるパラメータ } ] }
              
              {  
  "requests": [  
    {  
      "target": "string",     // 必須、プッシュ対象(registration_idまたはalias"platform": "string",   // 必須、プッシュプラットフォーム設定(プッシュAPIを参照)
      "notification": "object",  // オプション、通知コンテンツ(プッシュAPIを参照)  
      "message": "object",     // オプション、カスタムメッセージ(プッシュAPIを参照)、notificationと同時に存在できません  
      "options": "object",     // オプション、プッシュオプション(プッシュAPIを参照)  
      "custom_args": "object"  // オプション、クライアントに渡されるパラメータ  
    }  
  ]  
}  

            
このコードブロックはフローティングウィンドウ内に表示されます

パラメータ説明

フィールド 必須 説明
requests はい 配列 バッチリクエスト配列(最大500アイテム、バッチ内のtargetは一意である必要があります)
target はい 文字列 対象値:
- /regidエンドポイント:registration_id
- /aliasエンドポイント:alias
platform はい 文字列 プッシュプラットフォーム:androidiosまたはall
notification いいえ オブジェクト 通知コンテンツ(プッシュAPIと同じ構造)
message いいえ オブジェクト カスタムメッセージ(プッシュAPIと同じ構造)
options いいえ オブジェクト プッシュオプション(例:time_to_liveapns_production
custom_args いいえ オブジェクト カスタムパススルーパラメータ

レスポンス例

成功レスポンス(すべて成功)

{ "results": { "registration_id_1": { "target": "registration_id_1", "success": true, "msg_id": 2460001 }, "registration_id_2": { "target": "registration_id_2", "success": true, "msg_id": 2460002 } } }
              
              {
  "results": {
    "registration_id_1": {
      "target": "registration_id_1",
      "success": true,
      "msg_id": 2460001
    },
    "registration_id_2": {
      "target": "registration_id_2",
      "success": true,
      "msg_id": 2460002
    }
  }
}

            
このコードブロックはフローティングウィンドウ内に表示されます

成功レスポンス(部分的なレート制限)

{ "rate_limit_info": { "message": "Some requests were rate limited during batch processing", "rate_limit_occurred": true }, "results": { "170976fa8a0771c2647": { "target": "170976fa8a0771c2647", "success": false, "error": { "code": 23008, "message": "Rate limit exceeded for the API" } }, "170976fa8a9277c25d4": { "target": "170976fa8a9277c25d4", "success": false, "error": { "code": 23008, "message": "Rate limit exceeded for the API" } } } }
              
              {
    "rate_limit_info": {
        "message": "Some requests were rate limited during batch processing",
        "rate_limit_occurred": true
    },
    "results": {
        "170976fa8a0771c2647": {
            "target": "170976fa8a0771c2647",
            "success": false,
            "error": {
                "code": 23008,
                "message": "Rate limit exceeded for the API"
            }
        },
        "170976fa8a9277c25d4": {
            "target": "170976fa8a9277c25d4",
            "success": false,
            "error": {
                "code": 23008,
                "message": "Rate limit exceeded for the API"
            }
        }
    }
}

            
このコードブロックはフローティングウィンドウ内に表示されます

失敗レスポンス(グローバルエラー)

{ "error": { "code": 21004, "message": "basic auth failed" } }
              
              {  
  "error": {  
    "code": 21004,  
    "message": "basic auth failed"  
  }  
}  

            
このコードブロックはフローティングウィンドウ内に表示されます

失敗レスポンス(パラメータエラー)

{ "error": { "code": 21003, "message": "Parameter value is invalid" } }
              
              {  
  "error": {  
    "code": 21003,  
    "message": "Parameter value is invalid"  
  }  
}  

            
このコードブロックはフローティングウィンドウ内に表示されます

エラーコード参考

エラーコード 説明 解決策 HTTPステータス
グローバルエラーコード
21004 Basic認証に失敗しました AppKey/MasterSecretを確認 401
21008 AppKeyの長さが24文字ではありません AppKeyの形式を確認 400
21038 アプリにプッシュ権限がありません アプリ設定を確認 400
21043 プッシュ権限がありません(支払い保留中) 請求情報を解決 400
23009 IPが許可リストに含まれていません サーバーIPを許可リストに追加 400
21009 内部システムエラー(再試行しないでください) 技術サポートに連絡 400
レート制限エラー
23008 APIレート制限に達しました 部分的な成功の場合は失敗したアイテムを再試行 400
パラメータエラー
21003 パラメータ値が無効です リクエストボディの形式を確認 400
21015 リクエストパラメータが無効です 必須フィールドを検証 400
21016 パラメータ検証に失敗しました フィールドの型と値の範囲を確認 400

全エラーコード:プッシュ作成API - レスポンス

注意事項

  1. レート制限処理:レート制限時に部分的な成功結果を返却します(成功したものはmsg_id、失敗したものはerror)。
  2. 重複チェック:バッチ内のすべてのtargetまたはcid値は一意である必要があります。
  3. 数量制限:1リクエストあたりの最大対象数は500です。
  4. エラー処理:グローバルエラー(例:認証失敗)の場合は、部分的な結果を返さずに即座に終了します。
icon
お問い合わせ