LINE Get Content: Handle 202 and External Media Downloads
A LINE media webhook is not the media file itself. For images, video, and audio, inspect message.contentProvider.type: line content uses the official Get content endpoint; external content uses the supplied original-content URL instead. A 202 response while video or audio is being prepared is not a completed download. LINE does not guarantee how long it stores user-sent content, so save authorized content promptly rather than treating a message ID as a permanent archive.
Key takeaways
- Choose the download route from the content provider, not just the media type.
- Get content uses
api-data.line.me, not the usualapi.line.mehost. - Keep webhook acceptance, media readiness, and successful storage as separate states.
- A preview is not the original; changing integrations does not recover deleted content.
Choose the LINE media download source first
The LINE Messaging API reference distinguishes LINE-hosted content from externally hosted content for image, video, and audio message objects.
| Incoming content | Retrieval route | Important boundary |
|---|---|---|
Image, video, or audio with contentProvider.type: line | Get content using message.id | The webhook contains metadata, not the binary file |
Image, video, or audio with contentProvider.type: external | Use contentProvider.originalContentUrl | Get content cannot retrieve this external file |
| A file message | Get content using its message ID | Preserve the file-message metadata; do not assume every message has contentProvider |
| Text | Store the webhook’s text | There is no API to fetch that text again later |
The last two distinctions matter when implementing a generic inbox. Do not reject a file merely because your image-specific branch expects contentProvider, and do not send a text-message ID to a binary-download operation.
For LINE-hosted media, the documented request is GET /v2/bot/message/{messageId}/content on api-data.line.me, authenticated with the channel access token. Keep the token on your backend. Use the message ID from the verified event associated with that channel—not a user ID, reply token, or event ID.
The receiving-messages guide also documents preview retrieval for images and videos. A preview can support a loading interface, but it does not establish that the original file was downloaded or saved.
Diagnose the result before retrying
According to the Get content reference, a successful 200 returns binary content; its format is indicated by the response Content-Type. Large video or audio content can still be in preparation when requested, producing 202 instead.
| Observation | Recommended next action |
|---|---|
200 with binary content | Stream to controlled storage, validate it, and record completion only after storage succeeds |
202 during video/audio retrieval | Keep the job pending; use the documented preparation-status endpoint before a later download attempt |
404 or 410 | Check the message ID, channel association, source branch, and returned error; do not assume endless retries can restore content |
| External URL fails | Inspect the external host and URL availability; LINE’s content endpoint is not a fallback for it |
| A thumbnail appears but the original is absent | Track preview and original separately; do not mark the attachment fully stored |
The preparation check is GET /v2/bot/message/{messageId}/content/transcoding, documented in the API reference. Follow that endpoint’s own host and response contract rather than copying the binary-download host into every request.
Use a bounded polling schedule and retry budget chosen for your application. These are operational recommendations, not a LINE completion-time guarantee. Do not treat every successful HTTP-class response as a usable file, and do not pass a preparation response to an image decoder or transcription service.
Save promptly without defeating unsend handling
LINE says content is automatically deleted after a certain period and provides no guaranteed storage duration. A stored message ID therefore proves only that you recorded the identifier; it does not promise future access to the bytes.
Recommended processing order:
- Authenticate and durably accept the event, retaining its channel and message context.
- Create a recoverable media job alongside the accepted record. The LINE batch-intake guide explains why accepting only part of a webhook request is unsafe.
- Fetch the original through the correct source branch. Apply byte limits, timeouts, and content checks before exposing it to agents or AI tools.
- Store an application-owned reference behind conversation-level authorization. Treat filenames and declared media types as untrusted inputs.
- If retrieval cannot finish, show an explicit unavailable state and arrange an authorized resend when appropriate.
For external URLs, validate destinations and redirects, exclude private network targets, and never forward a LINE channel token to the external host. Avoid logging tokens or signed URL query strings. These are recommended worker safeguards, not claims about filtering performed by LINE.
Saving media also creates cleanup responsibility. Follow the LINE unsend cleanup workflow and check deletion state before publishing a completed download. A download that finishes after an unsend must not restore the attachment to the inbox.
Keep the UnifyPort attachment contract separate
UnifyPort’s unofficial interface uses a normalized message.received event, not the native LINE message object. Its media fields live in data.message.attachments[]; the standard event reference documents temporary signed OSS URLs, attachment types, and media metadata.
Do not pass a normalized message ID into LINE Get content or assume that contentProvider is present. Process the supplied attachment URL under your retention policy. If no URL is present, record that limitation rather than constructing one. The public reference does not document an attachment-URL refresh endpoint or guaranteed replay of missed messages.
For this separate receiver, enable signing_secret and follow the webhook delivery contract for raw-body HMAC-SHA256 verification and durable acceptance. A valid signature authenticates delivery; it does not prove that attachment bytes remain available or are safe to process.
Keep the official Messaging API when your integration needs the LINE Official Account identity and its native content contract. UnifyPort is not a recovery service for an unavailable Official Account attachment.
FAQ
Does 202 mean LINE downloaded the file successfully?
No. For video or audio that is still being prepared, the content request can return 202 without the binary data. Check preparation status and download later within your retry policy.
Can Get content download an external image?
No. For contentProvider.type: external, use contentProvider.originalContentUrl with your own safe-fetch controls.
How many days will LINE retain the content?
LINE does not guarantee the duration. Do not build a fixed-day recovery promise into your support interface.
Next step and sources
Test a LINE-hosted image, an external image, pending video/audio preparation, unavailable content, and unsend during a download. These are proposed checks, not reported test results. For normalized intake, start with the message.received reference.
Official sources checked on 2026-11-17:
Turn messaging integration into a stable product pipeline.
Start by sending through one API, then bring every inbound message back into your business system with standard events.