wp_remote_post timeout: calling a video API from WordPress
wp_remote_post waits 5 seconds by default. Set timeout yourself, submit the video job, and let a callback deliver the result instead of waiting.

wp_remote_post() waits 5 seconds by default: the timeout argument of the underlying WP_Http::request() defaults to 5. Pass your own timeout for any call that matters. When you submit a video job to Sume, the request only has to be accepted: POST /v1/videos answers 202 with a job id and status: pending, so the timeout covers the submit, not the render.
WordPress facts come from the developer reference pages for wp_remote_post(), WP_Http::request() and wp_remote_retrieve_response_code(), read 2026-09-29. Sume facts come from Videos and Jobs and results. Sume has no WordPress plugin: this is a plain HTTPS call from your PHP.
What is the default timeout of wp_remote_post()?
Five seconds. wp_remote_post() hands your arguments to WP_Http::request(), which documents timeout as how long the connection should stay open, with a default of 5. It returns an array on success and a WP_Error on failure, so a timeout arrives as an error object, not as an exception.
| Argument | Default | What it does |
|---|---|---|
timeout | 5 | How long the connection stays open, in seconds |
redirection | 5 | Number of allowed redirects |
blocking | true | Whether your code needs the response; false returns without one |
sslverify | true | Whether to verify SSL for the request |
How do I submit a Sume video job from WordPress?
Send JSON to https://api.sume.com/v1/videos with your key as a Bearer token, an Idempotency-Key, and a callback_url. You don't need 'method' => 'POST': the WordPress reference notes that wp_remote_post already sets it. Build the key from something stable, such as the order or post id, so a retry sends the same key and the same body.
$response = wp_remote_post( 'https://api.sume.com/v1/videos', array(
'timeout' => 20,
'headers' => array(
'Authorization' => 'Bearer ' . getenv( 'SUME_API_KEY' ),
'Content-Type' => 'application/json',
'Idempotency-Key' => 'post-' . $post_id . '-video',
),
'body' => json_encode( array(
'model' => 'seedance-2',
'prompt' => 'A ceramic mug on a wooden desk, morning light',
'aspect_ratio' => '9:16',
'callback_url' => 'https://example.com/wp-json/acme/v1/sume',
) ),
) );
if ( is_wp_error( $response ) ) {
error_log( $response->get_error_message() );
return; // the job may exist: retry with the same key and body
}
if ( 202 === wp_remote_retrieve_response_code( $response ) ) {
$job = json_decode( wp_remote_retrieve_body( $response ), true );
update_post_meta( $post_id, 'sume_job_id', $job['id'] );
}What should I do when the request times out?
Retry with the same Idempotency-Key and the same body. Sume's docs say a client-side timeout does not cancel the job: it keeps running and still bills, and you have only stopped watching. A replayed key returns the original job instead of creating a second one. The docs say to reuse a key only for the same operation and payload, so don't change fields on the retry.
- Keep the
wp_remote_posttimeout above what a plain submit needs, and don't stretch it to cover the render. - Store the returned
idon the post (as above) so a later status check can find the job. - Don't submit a new job with a new key for the same intent: the retry with the original key is what avoids billing a second job.
Can I set blocking to false and skip the wait?
Not for the submit. WordPress says a blocking => false request is sent and control returns at once, but you receive no response from the remote server. Without the response you don't have the job id, so you can't store it or poll it. Use blocking => false only for calls whose result you never need.
How do I get the finished video without waiting in PHP?
Give Sume a callback_url. Sume POSTs to it once the job reaches a terminal state, signs the raw body, and sends x-sume-webhook-timestamp and x-sume-webhook-signature headers; see Webhooks. The URL must be public HTTPS. Keep polling GET /v1/videos/{jobId} as a backup for deliveries that never arrive.
Keep the key on the server. Sume's Authentication docs tell you to keep API keys on trusted servers and have browsers call your backend, so never print it into a theme, a block or admin JavaScript.
Sources
Related posts
More in Integrations
- How to add an MCP server to ChatGPT with developer mode
Turn on ChatGPT developer mode, create an app for the server's URL, and sign in with OAuth. The steps, with Sume's hosted MCP server as the example.
- How to add subtitles to a video in Python
Add subtitles to a video in Python with Requests: POST the video URL to Sume's /v1/video-captions, poll the job, then read the captioned video_url.
- Add Sume to Claude as a custom connector (remote MCP)
Add Sume's hosted MCP server to Claude under Customize > Connectors, see what Sume's OAuth consent grants, and decide whether to allow paid tools.
- Airflow HTTP sensor: wait for an AI video job to finish
Submit an AI video job with Airflow's HttpOperator, then wait with an HttpSensor in reschedule mode that passes once the job's status is completed.
Written by Sume