Przejdź do głównej zawartości

Wypełnij szablon danymi

POST
/api/v1/Templates
curl --request POST \
--url https://twoja-instancja-template-engine-api.enterprise.sellrocket.pl/api/v1/Templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "template": "example", "data": { "additionalProperty": "example" } }'

Renderuje szablon tekstowy (składnia {{pole}}) na podstawie przekazanych danych i zwraca wynik; brakujące klucze dają puste miejsca. Przydatne do generowania treści wiadomości lub dokumentów.

If the data passed to the endpoint will not contain keys from template, segments where values should be located will be empty.


Example

Sending request like

{
    "template": "zamowienie nr {{id}}, status: {{status.id}}, komentarz: {{NOT_EXISTING.comment}}",
    "data": {
        "id": 877,
        "source": {
            "connectionId": 12,
            "connectionType": "MAG2",
            "platformAccountId": "",
            "platformOrderId": "1"
        },
        "status": {
            "id": 1212121,
            "from": "2023-12-14T11:56:18.511114Z"
        }
    }
}

Where there is no object NOT_EXISTING will return template zamowienie nr 877, status: 1212121, komentarz:

object
template
string
nullable
data
object
key
additional properties
Examplegenerated
{
"template": "example",
"data": {
"additionalProperty": "example"
}
}

Success

Typ treściapplication/json
string
Examplegenerated
example

Bad Request

Typ treściapplication/json
object
statusCode
integer format: int32
Examplegenerated
{}

Server Error