Skip to content
campaiDeveloper
campai.com

Crm · Contacts

POST/{organizationId}/{mandateId}/crm/contacts/message/template/copyReads only

Copy message template

Copies a published contact or transactional content template into temporary message resources. Provide the organization, mandate and template IDs and an email or letter channel. The response contains the design and its copied resources, plus copied email attachments when applicable.

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 with template.read and dispatchDocument.insert permissions.
  • The caller must also have mandate.read permission for the supplied mandate.

Request

Path parameters

  • organizationIdidrequired
  • mandateIdidrequired

Body

Content-Type: application/json

  • templateIdidrequired
  • channelstringrequired
    email letter
Request
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
  --request POST 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/crm/contacts/message/template/copy' \
  --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

  • designobject
    Variant 1: 5 properties
    • versionnumber
    • channelstring
    • containerobject
      8 properties
      • typestring
      • idstring

        pattern ^[a-zA-Z0-9_-]+$

      • desktopobject
        1 property
        • paddingany[]

          exactly 4 items

      • mobileobject
        1 property
        • paddingany[]nullable

          exactly 4 items

      • widthinteger
      • fontFamilystring
        17 values
        System Arial, Helvetica, sans-serif Arial Black, Gadget, sans-serif Comic Sans MS, Textile, Cursive, sans-serif Courier New, Courier, Monospace, monospace Georgia, Times New Roman, Times, serif Helvetica, Arial, serif Impact, Charcoal, sans-serif Lucida Console, Monaco, Monospace, monospace Lucida Sans Unicode, Lucida Grande, sans-serif Palatino Linotype, Book Antiqua, Palatino, serif Tahoma, Geneva, sans-serif Times New Roman, Times, serif Trebuchet MS, Helvetica, sans-serif Verdana, Geneva, sans-serif MS Sans Serif, Geneva, sans-serif MS Serif, New York, serif
      • backgroundobject
        3 properties
        • backgroundColorobject
          2 properties
          • colorstring

            pattern ^#[0-9A-F]{6}$

          • hideboolean
        • backgroundGradientobject
          3 properties
          • hideboolean
          • stopsobject[]
            2 properties
            • colorstring

              pattern ^#[0-9A-F]{6,8}$

            • positionnumber

              at least 0

          • angleinteger
        • backgroundImageobject
          4 properties
          • hideboolean
          • imageobjectnullable
          • sizestring
            cover contain fill tile
          • positionstring
            top left top center top right middle left middle center middle right bottom left bottom center bottom right
      • itemsobject[]
        14 properties
        • idstring

          pattern ^[a-zA-Z0-9_-]+$

        • namestring

          at most 32 characters

        • hideOnMobileboolean
        • hideOnDesktopboolean
        • hiddenboolean
        • lockedboolean
        • conditionobjectnullable
          2 properties
          • operatorstring
            and or
          • conditions(object (recursive) | object)[]

            at least 1 items

            4 properties
            • leftobject | object of any
              Variant 1: 1 property
              • variablestring

                at least 1 characters

              Variant 2: 4 properties
              • sourceobject
                1 property
                • variablestring

                  at least 1 characters

              • lookupobjectnullable
                1 property
                • variablestring

                  at least 1 characters

              • arrayboolean
              • selectobject (recursive)
              Variant 3: 2 properties
              • funcstring
                33 values
                concat ifEmpty lowercase uppercase substring trim abs ceil floor min max mod sum sub mul div avg med parseNumber formatNumber dateOnly dateTime dateOnlyPart dateTimePart age dateOnlyDifference dateTimeDifference setDateOnly setDateTime addDateOnly addDateTime formatDateOnly formatDateTime
              • paramsobject (recursive)[]
              Variant 4: 1 property
              • literalnumber[] | number
              Variant 5: 3 properties
              • ifobject (recursive)
              • thenobject (recursive)
              • elseobject (recursive)
            • cmpFuncstring
              15 values
              eq isSet lt lte gt gte includes contains startsWith endsWith before beforeAt after afterAt isToday
            • rightobject | object of any
              Variant 1: 1 property
              • variablestring

                at least 1 characters

              Variant 2: 4 properties
              • sourceobject
                1 property
                • variablestring

                  at least 1 characters

              • lookupobjectnullable
                1 property
                • variablestring

                  at least 1 characters

              • arrayboolean
              • selectobject (recursive)
              Variant 3: 2 properties
              • funcstring
                33 values
                concat ifEmpty lowercase uppercase substring trim abs ceil floor min max mod sum sub mul div avg med parseNumber formatNumber dateOnly dateTime dateOnlyPart dateTimePart age dateOnlyDifference dateTimeDifference setDateOnly setDateTime addDateOnly addDateTime formatDateOnly formatDateTime
              • paramsobject (recursive)[]
              Variant 4: 1 property
              • literalnumber[] | number
              Variant 5: 3 properties
              • ifobject (recursive)
              • thenobject (recursive)
              • elseobject (recursive)
            • negateboolean
        • desktopobject
          3 properties
          • marginany[]

            exactly 4 items

          • paddingany[]

            exactly 4 items

          • radiusnumber | any[]
        • mobileobject
          3 properties
          • marginany[]nullable

            exactly 4 items

          • paddingany[]nullable

            exactly 4 items

          • radiusnumber | any[]nullable
        • typestring
        • repeatobjectnullable
          1 property
          • sourceobject
            1 property
            • variablestring

              at least 1 characters

        • backgroundobject
          3 properties
          • backgroundColorobject
            2 properties
            • colorstring

              pattern ^#[0-9A-F]{6}$

            • hideboolean
          • backgroundGradientobject
            3 properties
            • hideboolean
            • stopsobject[]
              2 properties
              • colorstring

                pattern ^#[0-9A-F]{6,8}$

              • positionnumber

                at least 0

            • angleinteger
          • backgroundImageobject
            4 properties
            • hideboolean
            • imageobjectnullable
            • sizestring
              cover contain fill tile
            • positionstring
              top left top center top right middle left middle center middle right bottom left bottom center bottom right
        • borderobject
          4 properties
          • colorstring

            pattern ^#[0-9A-F]{6}$

          • widthnumber | any[]
          • stylestring
            solid dotted dashed
          • hideboolean
        • itemsobject[]
    • languagesstring[]

      at least 1 items · each at least 2 characters

    • resourcesobject[]
      5 properties
      • resourcestring

        at least 1 characters

      • fileNamestring

        at most 128 characters

      • contentTypestring

        at most 75 characters

      • fileSizeBytesinteger

        at least 0

      • idstring

        exactly 6 characters

    Variant 2: 8 properties
    • versionnumber
    • channelstring
    • containerobject
      6 properties
      • typestring
      • idstring

        pattern ^[a-zA-Z0-9_-]+$

      • repeatobjectnullable
        1 property
        • sourceobject
          1 property
          • variablestring

            at least 1 characters

      • pageSizeobject
        3 properties
        • widthnumber
        • heightnumber
        • landscapeboolean
      • fontFamilystring
      • itemsobject[]
        11 properties
        • idstring

          pattern ^[a-zA-Z0-9_-]+$

        • namestring

          at most 32 characters

        • hiddenboolean
        • lockedboolean
        • conditionobjectnullable
          2 properties
          • operatorstring
            and or
          • conditions(object (recursive) | object)[]

            at least 1 items

            4 properties
            • leftobject | object of any
              Variant 1: 1 property
              • variablestring

                at least 1 characters

              Variant 2: 4 properties
              • sourceobject
                1 property
                • variablestring

                  at least 1 characters

              • lookupobjectnullable
                1 property
                • variablestring

                  at least 1 characters

              • arrayboolean
              • selectobject (recursive)
              Variant 3: 2 properties
              • funcstring
                33 values
                concat ifEmpty lowercase uppercase substring trim abs ceil floor min max mod sum sub mul div avg med parseNumber formatNumber dateOnly dateTime dateOnlyPart dateTimePart age dateOnlyDifference dateTimeDifference setDateOnly setDateTime addDateOnly addDateTime formatDateOnly formatDateTime
              • paramsobject (recursive)[]
              Variant 4: 1 property
              • literalnumber[] | number
              Variant 5: 3 properties
              • ifobject (recursive)
              • thenobject (recursive)
              • elseobject (recursive)
            • cmpFuncstring
              15 values
              eq isSet lt lte gt gte includes contains startsWith endsWith before beforeAt after afterAt isToday
            • rightobject | object of any
              Variant 1: 1 property
              • variablestring

                at least 1 characters

              Variant 2: 4 properties
              • sourceobject
                1 property
                • variablestring

                  at least 1 characters

              • lookupobjectnullable
                1 property
                • variablestring

                  at least 1 characters

              • arrayboolean
              • selectobject (recursive)
              Variant 3: 2 properties
              • funcstring
                33 values
                concat ifEmpty lowercase uppercase substring trim abs ceil floor min max mod sum sub mul div avg med parseNumber formatNumber dateOnly dateTime dateOnlyPart dateTimePart age dateOnlyDifference dateTimeDifference setDateOnly setDateTime addDateOnly addDateTime formatDateOnly formatDateTime
              • paramsobject (recursive)[]
              Variant 4: 1 property
              • literalnumber[] | number
              Variant 5: 3 properties
              • ifobject (recursive)
              • thenobject (recursive)
              • elseobject (recursive)
            • negateboolean
        • typestring
        • repeatobjectnullable
          1 property
          • sourceobject
            1 property
            • variablestring

              at least 1 characters

        • marginany[]

          exactly 4 items

        • backgroundobject
          3 properties
          • backgroundColorobject
            2 properties
            • colorstring

              pattern ^#[0-9A-F]{6}$

            • hideboolean
          • backgroundGradientobject
            3 properties
            • hideboolean
            • stopsobject[]
              2 properties
              • colorstring

                pattern ^#[0-9A-F]{6,8}$

              • positionnumber

                at least 0

            • angleinteger
          • backgroundImageobject
            4 properties
            • hideboolean
            • imageobjectnullable
            • sizestring
              cover contain fill tile
            • positionstring
              top left top center top right middle left middle center middle right bottom left bottom center bottom right
        • foldingMarksobject[]
          3 properties
          • topnumber
          • leftnumber
          • widthnumber
        • itemsobject[]
    • unitstring
      px pt mm in
    • languagesstring[]

      at least 1 items · each at least 2 characters

    • onlineLetterboolean
    • resourcesobject[]
      5 properties
      • resourcestring

        at least 1 characters

      • fileNamestring

        at most 128 characters

      • contentTypestring

        at most 75 characters

      • fileSizeBytesinteger

        at least 0

      • idstring

        exactly 6 characters

    • attachmentobjectnullable
      3 properties
      • resourceIdstring

        exactly 6 characters

      • modestring
        overlay prepend append
      • pagesinteger
  • attachmentsobject[]

    attachments is empty for the letter channel.

    5 properties
    • resourcestring

      at least 1 characters

    • fileNamestring

      at most 128 characters

    • contentTypestring

      at most 75 characters

    • fileSizeBytesinteger

      at least 0

    • idstring

      exactly 6 characters

Response200
{
  "design": {
    "version": 1,
    "channel": "email",
    "container": {
      "type": "container",
      "id": "string",
      "desktop": {
        "padding": [
          null
        ]
      },
      "mobile": {
        "padding": [
          null
        ]
      },
      "width": 1,
      "fontFamily": "System",
      "background": {
        "backgroundColor": {
          "color": "string",
          "hide": true
        },
        "backgroundGradient": {
          "hide": true,
          "stops": [
            {
              "color": "string",
              "position": 0
            }
          ],
          "angle": 1
        },
        "backgroundImage": {
          "hide": true,
          "image": {
            "type": "resource",
            "resourceId": "string"
          },
          "size": "cover",
          "position": "top left"
        }
      },
      "items": [
        {
          "id": "string",
          "name": "string",
          "hideOnMobile": true,
          "hideOnDesktop": true,
          "hidden": true,
          "locked": true,
          "condition": {
            "operator": "and",
            "conditions": [
              null
            ]
          },
          "desktop": {
            "margin": [
              null
            ],
            "padding": [
              null
            ],
            "radius": 0
          },
          "mobile": {
            "margin": [
              null
            ],
            "padding": [
              null
            ],
            "radius": 0
          },
          "type": "block",
          "repeat": {
            "source": {
              "variable": "string"
            }
          },
          "background": {
            "backgroundColor": {
              "color": "string",
              "hide": true
            },
            "backgroundGradient": {
              "hide": true,
              "stops": [
                {
                  "color": "string",
                  "position": 0
                }
              ],
              "angle": 1
            },
            "backgroundImage": {
              "hide": true,
              "image": {
                "type": "resource",
                "resourceId": "string"
              },
              "size": "cover",
              "position": "top left"
            }
          },
          "border": {
            "color": "string",
            "width": 0,
            "style": "solid",
            "hide": true
          },
          "items": [
            {
              "id": "string",
              "name": "string",
              "hideOnMobile": true,
              "hideOnDesktop": true,
              "hidden": true,
              "locked": true,
              "condition": {
                "operator": "and",
                "conditions": [
                  null
                ]
              },
              "desktop": {
                "width": {
                  "type": "hug",
                  "width": {
                    "value": 0,
                    "unit": "#"
                  }
                }
              },
              "mobile": {
                "width": {
                  "type": "hug",
                  "width": {
                    "value": null,
                    "unit": "#"
                  }
                }
              },
              "type": "table",
              "align": "left",
              "border": {
                "color": "string",
                "width": 0,
                "style": "solid",
                "hide": true
              },
              "collapseMobile": true,
              "items": [
                {
                  "id": "string",
                  "name": "string",
                  "hideOnMobile": true,
                  "hideOnDesktop": true,
                  "hidden": true,
                  "locked": true,
                  "condition": null,
                  "desktop": {
                    "placement": "top left",
                    "height": {
                      "value": null,
                      "unit": "#"
                    }
                  },
                  "mobile": {
                    "placement": "top left",
                    "height": null
                  },
                  "type": "tableRow",
                  "repeat": {
                    "source": null
                  },
                  "backgroundColor": {
                    "color": "string",
                    "hide": true
                  },
                  "border": {
                    "color": "string",
                    "width": null,
                    "style": "solid",
                    "hide": true
                  },
                  "items": [
                    {
                      "id": null,
                      "name": null,
                      "hideOnMobile": null,
                      "hideOnDesktop": null,
                      "hidden": null,
                      "locked": null,
                      "condition": null,
                      "desktop": null,
                      "mobile": null,
                      "type": "tableCell",
                      "background": null,
                      "items": null
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    "languages": [
      "string"
    ],
    "resources": [
      {
        "resource": "string",
        "id": "string"
      }
    ]
  },
  "attachments": [
    {
      "resource": "string",
      "id": "string"
    }
  ]
}

What else happens

  • Copies design resources and, for email, attachments to temporary storage.
  • If copying fails, the endpoint attempts to remove the temporary resources created during the request.

Errors

Other errors

StatusErrorWhen
400No fixed messageReturns HTTP 400 if the template has no design for the requested channel.
400No fixed messageReturns HTTP 400 if a resource path is outside the template's resource prefix or contains a .. path segment.
404No fixed messageReturns HTTP 404 if the template is not found, is archived or unpublished, or is not a contact or transactional content template.
404No fixed messageReturns HTTP 404 if a resource cannot be copied.

Errors nearly every request can meet are listed under Errors.