Skip to content

Latest commit

 

History

History
172 lines (130 loc) · 4.67 KB

File metadata and controls

172 lines (130 loc) · 4.67 KB

Backend-api

Template UI backend APIs

Template APIs

The openapi3 spec can found in the terraform module in spec.tmpl.json.

If you have postman installed you can import the spec file and make request via postman.

Get an Access token

Setup an authenticated AWS terminal and run

./scripts/sandbox_auth.sh <email> <password>

Grab the AccessToken and api_base_url from sandbox_cognito_auth_token.json

SANDBOX_TOKEN=$(jq -r .AccessToken sandbox_cognito_auth_token.json) && APIG_STAGE=$(jq -r .api_base_url.value ./sandbox_tf_outputs.json)

GET - /v1/template/:templateId - Get a single template by id

Get a single template by id

curl --location "${APIG_STAGE}/v1/template/${TEMPLATE_ID}" \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN"

POST - /v1/template/:templateId - Update a template

Will update template properties excluding templateStatus

curl -X POST --location "${APIG_STAGE}/v1/template/${TEMPLATE_ID}" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN" \
--data '{
  "name": "<string>",
  "message": "<string>",
  "templateType": "SMS",
  "subject": "<string>"
}'

GET - /v1/templates - Get all templates

currently limited to 50 items

curl --location "${APIG_STAGE}/v1/templates" \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN"

POST - /v1/template - Create a template

Will create a single template.

curl -X POST --location "${APIG_STAGE}/v1/template" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN" \
--data '{
  "templateType": "EMAIL",
  "name": "<string>",
  "message": "<string>",
  "subject": "<string>"
}'

POST - /v1/letter-template - Create a letter template

Will create a single letter template. The CSV form part is optional. Do not set a content type header as this must be auto-generated by curl, so that it includes a form-data boundary.

PDF_PATH="./tests/test-team/fixtures/pdf-upload/with-personalisation/template.pdf"
CSV_PATH="./tests/test-team/fixtures/pdf-upload/with-personalisation/test-data.csv"
curl -X POST --location "${APIG_STAGE}/v1/letter-template" \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN" \
--form "letterPdf=@${PDF_PATH};type=application/pdf;filename=template.pdf" \
--form "testCsv=@${CSV_PATH};type=text/csv;filename=test.csv" \
--form 'template={
  "templateType": "LETTER",
  "name": "example letter",
  "letterType": "x0",
  "language": "en"
}'

DELETE - /v1/template/:templateId - Delete a template

Will delete a single template.

curl -X POST --location "${APIG_STAGE}/v1/template/${TEMPLATE_ID" \
--header "Authorization: $SANDBOX_TOKEN"

PATCH - /v1/template/:templateId/submit - Submit a template

Will submit a template.

curl -X PATCH --location "${APIG_STAGE}/v1/template/${TEMPLATE_ID}/submit" \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN"

POST - /v1/template/:templateId/proof - Request a proof of a template

Will trigger a proof request for the template.

curl -X POST --location "${APIG_STAGE}/v1/template/${TEMPLATE_ID}/proof" \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN"

GET - /v1/client-configuration - Get client configuration for the caller

curl --location "${APIG_STAGE}/v1/client-configuration" \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN"

GET - /v1/routing-configuration/:routingConfigId - Get a routing configuration by id

curl --location "${APIG_STAGE}/v1/routing-configuration/${ROUTING_CONFIG_ID}" \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN"

GET - /v1/routing-configurations - List routing configurations

curl --location "${APIG_STAGE}/v1/routing-configurations" \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN"

POST - /v1/routing-configuration - Create a routing configuration

curl -X POST --location "${APIG_STAGE}/v1/routing-configuration" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: $SANDBOX_TOKEN" \
--data '{
  "campaignId": "campaign",
  "cascade": [{
      "cascadeGroups": ["standard"],
      "channel": "EMAIL",
      "channelType": "primary",
      "defaultTemplateId": "email_id"
   }],
  "cascadeGroupOverrides": [{ "name": "standard" }],
  "name": "RC name"
}'