Skip to content
campaiDeveloper
campai.com

Crm · Social posts

POST/{organizationId}/crm/communication/socialPosts/publish

Publish social post

Publishes or schedules a social post using its text, media, targets and optional postId. It can also edit a scheduled post or correct and republish failed accounts on a post that has started publishing. Returns the postId.

Permissions

Send an API key of the organization in the path, using the X-API-Key header.

Who may call it

  • The caller must have organization access. An existing post requires social.edit; a new post requires social.insert.

Request

Path parameters

  • organizationIdidrequired

Body

Content-Type: application/json

  • postIdid
  • scheduledAtstring · date-timerequirednullable
  • textstringrequired

    at most 63206 characters

  • mediaobject[]required

    at most 35 items

    4 properties
    • fileIdstring · uuid

      pattern ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$

    • resourcestring

      at least 1 characters

    • fileNamestringrequirednullable

      at most 128 characters

    • kindstringrequired
      image video
  • targetsobject[]required

    1–50 items

    4 properties
    • accountIdidrequired
    • textstringrequirednullable

      at most 63206 characters

    • mediaobject[]requirednullable

      at most 35 items

      4 properties
      • fileIdstring · uuid

        pattern ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$

      • resourcestring

        at least 1 characters

      • fileNamestringrequirednullable

        at most 128 characters

      • kindstringrequired
        image video
    • settingsobjectrequired
      8 properties
      • titlestringrequirednullable

        at most 500 characters

      • boardIdstringrequirednullable

        at most 200 characters

      • privacystringrequirednullable

        at most 100 characters

      • disableCommentboolean

        default true

      • disableDuetboolean

        default true

      • disableStitchboolean

        default true

      • brandContentboolean

        default false

      • brandOrganicboolean

        default false

Request
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
  --request POST 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/crm/communication/socialPosts/publish' \
  --header 'X-API-Key: YOUR_API_KEY'

No request that worked has been recorded yet, so the body is not shown.

Response

200 Successful response

Content-Type: application/json

  • postIdid
Response200
{
  "postId": "000000000000000000000001"
}

What else happens

  • Creates a new socialPosts record when no existing post is supplied.
  • Updates the content and targets of an existing scheduled post.
  • Updates the selected deliveries of a post being corrected.
  • When a correction leaves no problems needing attention, matching post notifications are deleted.
  • When unread notifications are cleared, their userWatchCounters are updated.
  • For an immediate publication, the endpoint submits a crm.processSocialPost job to DefaultQueue. If submission fails, the saved publication can be recovered by the scheduler.

Errors

Other errors

StatusErrorWhen
400A post that has already started publishing cannot be rescheduled. Correct it and publish it again right away.A correction to a post that has started publishing cannot be scheduled. The response is HTTP 400 with key socialPost.correctionNotScheduled.
400Each account can only be selected once.If an account is selected more than once, the response is HTTP 400 with key socialPost.duplicateAccounts.
400These accounts are no longer connected: names. Reconnect them or remove them from the post.If a selected account is not connected to the organization, the response is HTTP 400 with key socialPost.accountsUnavailable.
400A file changed its type. Remove it and upload it again.If the same file is specified with different kinds, or a reused file's kind differs from its stored kind, the response is HTTP 400 with key socialPost.mediaKindMismatch.
400A post can contain at most count different files across all accounts.If the post has too many different files across its accounts, the response is HTTP 400 with key socialPost.mediaTooMany.
400The uploaded file “name” is no longer available. Add it again.If a referenced file is no longer available, the response is HTTP 400 with key socialPost.mediaExpired.
400The file “name” is empty, has the wrong type or is larger than 100 MB.If a file is empty, has the wrong type or exceeds the size limit, the response is HTTP 400 with key socialPost.mediaInvalid.
409This publication can no longer be retried or checked. Refresh its status.If a correction targets a delivery that cannot be retried, including one that becomes non-retryable during the request, the response is HTTP 409 with key socialPost.deliveryNotRetryable.
409This post is no longer scheduled. It may already be publishing.If a post being edited is no longer scheduled, the response is HTTP 409 with key socialPost.notScheduled.

Marked words such as names are filled in with the actual value when the error happens.

Errors nearly every request can meet are listed under Errors.