Skip to content

SendPostByUrl#

Beta version

The functionality is in beta. Features may change and may also work unstably.

The method publishes a post to the account feed. The file is passed by a link - a photo or a video.

Files

The file has to meet the Instagram requirements - otherwise the post is not published and the reason arrives in the notification.

An image is not cropped: if its aspect ratio is outside the allowed range, it is fitted into the frame with padding.

A video can be from 3 to 60 seconds long and has type = reel. A longer video has to be published by the SendReelByUrl method.

The method uses the limits on the number of requests per second.

Request#

To publish a post, you have to execute a request at:

POST
{{apiUrl}}/waInstance{{idInstance}}/sendPostByUrl/{{apiTokenInstance}}

For apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Request parameters#

Parameter Type Mandatory Description
urlFile string Yes The link to the file being published: an image or a video
caption string No The caption of the post. The maximum length is 2200 characters
disableComments boolean No Publish the post with closed comments. The default is false

Request body example#

Create a post with an image:#

{
    "urlFile": "https://example.com/photo.jpg",
    "caption": "The caption of the post"
}

Create a post with a video:#

{
    "urlFile": "https://example.com/clip.mp4",
    "caption": "The caption of the post"
}

Create a post with closed comments:#

{
    "urlFile": "https://example.com/photo.jpg",
    "caption": "The caption of the post",
    "disableComments": true
}

Response#

Response parameters#

Field Type Description
postId string The post identifier. The link to it is returned by GetPostInfo

Response body example#

{
    "postId": "2907515653209522683"
}

SendPostByUrl errors#

For a list of errors common to all methods, refer to the Common errors section

HTTP code Error ID Description
400 Bad Request
Validation failed
Validation error
400 Validation failed. Details:
'urlFile' is required
The link to the file is not passed
400 Validation failed. Details:
'urlFile' must be a valid uri with a scheme matching the http\|https pattern
The link is not an http or https address

Refusals in the notification#

The command is executed through the queue: the method responds with 200 and postId at once. If the command could not be executed, the outgoingPostStatus notification arrives with status = failed, the reason is in the description field:

description Description
uploader answered 400: request was failed with bad status code (404). URL: 'http://example.com/file.mp4' The file is not available at the specified link. The HTTP code of the response of the server that hosts the file is in the brackets
unsupported file type for instagram post: application/octet-stream What the link points to is neither an image nor a video of a suitable format
post upload: video duration 310000 ms is outside 3000 … 60000 The duration of the video is outside the allowed range, in milliseconds. A video longer than 60 seconds is published by the SendReelByUrl method
post upload: video aspect ratio 2.40 is outside 0.5625 … 1.91 The aspect ratio of the video is outside the allowed range

Request examples#

import requests

url = "{{apiUrl}}/waInstance{{idInstance}}/sendPostByUrl/{{apiTokenInstance}}"

payload = {
    "urlFile": "https://example.com/photo.jpg",
    "caption": "The caption of the post"
}
headers = {'Content-Type': 'application/json'}

response = requests.post(url, json=payload, headers=headers)

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/sendPostByUrl/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "urlFile": "https://example.com/photo.jpg",
    "caption": "The caption of the post"
}'