← All posts
Guide

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 usual api.line.me host.
  • 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 contentRetrieval routeImportant boundary
Image, video, or audio with contentProvider.type: lineGet content using message.idThe webhook contains metadata, not the binary file
Image, video, or audio with contentProvider.type: externalUse contentProvider.originalContentUrlGet content cannot retrieve this external file
A file messageGet content using its message IDPreserve the file-message metadata; do not assume every message has contentProvider
TextStore the webhook’s textThere 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.

ObservationRecommended next action
200 with binary contentStream to controlled storage, validate it, and record completion only after storage succeeds
202 during video/audio retrievalKeep the job pending; use the documented preparation-status endpoint before a later download attempt
404 or 410Check the message ID, channel association, source branch, and returned error; do not assume endless retries can restore content
External URL failsInspect the external host and URL availability; LINE’s content endpoint is not a fallback for it
A thumbnail appears but the original is absentTrack 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:

  1. Authenticate and durably accept the event, retaining its channel and message context.
  2. 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.
  3. Fetch the original through the correct source branch. Apply byte limits, timeouts, and content checks before exposing it to agents or AI tools.
  4. Store an application-owned reference behind conversation-level authorization. Treat filenames and declared media types as untrusted inputs.
  5. 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:

UnifyPort API

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.