Skip to main content
PATCH
/
v1
/
templates
/
{id}
Editar un template existente
curl --request PATCH \
  --url https://api.keebai.com/v1/templates/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "channel_id": "<string>",
  "name": "<string>",
  "language": "<string>",
  "components": [
    {
      "text": "<string>",
      "buttons": [
        {
          "text": "<string>",
          "url": "<string>",
          "phone_number": "<string>",
          "example": [
            "<string>"
          ],
          "flow_id": "<string>",
          "coupon_code": "<string>",
          "autofill_text": "<string>",
          "package_name": "<string>",
          "signature_hash": "<string>"
        }
      ],
      "example": {
        "header_text": [
          "<string>"
        ],
        "header_text_named_params": [
          {
            "param_name": "nombre",
            "example": "Lucio"
          }
        ],
        "header_handle": [
          "<string>"
        ],
        "body_text": [
          "<string>"
        ],
        "body_text_named_params": [
          {
            "param_name": "nombre",
            "example": "Lucio"
          }
        ]
      },
      "add_security_recommendation": true,
      "code_expiration_minutes": 123
    }
  ],
  "metadata": {}
}
'
{
  "id": "<string>",
  "name": "<string>",
  "language": "<string>",
  "status": "<string>",
  "category": "<string>",
  "variables": [
    "<string>"
  ],
  "parameter_format": "<string>"
}
Updates an existing template. Internally syncs the changes with Meta when applicable (for example when editing components or category). Only send the fields you want to change; the rest stays as-is.
Meta only allows editing templates in certain states (APPROVED, REJECTED, or PAUSED, depending on the field). Editing a template in PENDING or IN_REVIEW may return 409 CONFLICT from upstream. If you need to change something critical before Meta approves it, it’s usually faster to create a new template with POST /v1/templates.

Endpoint

PATCH https://api.keebai.com/v1/templates/{id}

Required scope

templates:update

Headers

HeaderRequiredValue
AuthorizationYesBearer kbai_pk_<token>
Content-TypeYesapplication/json

Path params

ParamTypeDescription
idstringInternal ObjectId of the template. This is the id returned by GET /v1/templates and POST /v1/templates.

Body

FieldTypeRequiredDescription
channel_idstringYesObjectId of the channel that owns the template. Required by upstream to validate ownership.
namestringNoNew name. Lowercase letters, numbers, and underscores only. Max 512.
languagestringNoLanguage code. Max 10.
categorystringNoMARKETING, UTILITY, or AUTHENTICATION.
parameter_formatstringNoNAMED or POSITIONAL.
componentsarrayNoReplaces the components list. Same structure as in POST /v1/templates.
statusstringNoStatus to force locally (PAUSED, DISABLED, etc.). Use with care.
metadataobjectNoFree-form metadata.

Example request

curl -X PATCH https://api.keebai.com/v1/templates/65f3a1b2c3d4e5f6a7b8c9d2 \
  -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "channel_id": "65f3a1b2c3d4e5f6a7b8c9d0",
    "components": [
      {
        "type": "BODY",
        "text": "Hola {{nombre}}, tu pedido por {{monto}} fue actualizado.",
        "example": {
          "body_text_named_params": [
            { "param_name": "nombre", "example": "Lucio" },
            { "param_name": "monto", "example": "$15.000" }
          ]
        }
      }
    ]
  }'

Response

200 OK

{
  "id": "65f3a1b2c3d4e5f6a7b8c9d2",
  "name": "welcome_v2",
  "language": "es_CL",
  "status": "PENDING",
  "category": "UTILITY",
  "parameter_format": "NAMED",
  "variables": ["nombre", "monto"]
}
Same shape as POST /v1/templates. If the edit triggered a fresh Meta review, status may sit in IN_REVIEW or PENDING until Meta approves it again.

400 / 401 / 403 / 404 / 409 / 429

Common cases:
  • 400 BAD_REQUEST: body validation.
  • 403 FORBIDDEN with code: INSUFFICIENT_SCOPE: the PAT does not have templates:update.
  • 404 NOT_FOUND: the template does not exist or does not belong to your tenant.
  • 409 CONFLICT: Meta rejected the edit because the template is not in an editable state.
  • 502 UPSTREAM_ERROR: generic error from Meta. details describes the cause.
After editing components, poll GET /v1/templates to confirm Meta has re-approved the template before continuing to send it in production.

Authorizations

Authorization
string
header
required

Personal Access Token con prefijo kbai_pk_. Generar desde el portal con permiso developer.manage_tokens.

Path Parameters

id
string
required

ObjectId del template

Body

application/json
channel_id
string
required

ObjectId del canal WhatsApp dueño del template (requerido por upstream).

name
string
Maximum string length: 512
language
string
Maximum string length: 10
category
enum<string>
Available options:
MARKETING,
UTILITY,
AUTHENTICATION
parameter_format
enum<string>
Available options:
NAMED,
POSITIONAL
components
object[]
status
enum<string>
Available options:
PENDING,
IN_REVIEW,
REJECTED,
APPROVED,
PAUSED,
DISABLED,
IN_APPEAL
metadata
object

Response

200 - application/json
id
string
required
name
string
required
language
string
required
status
string
required
category
string
required
variables
string[]
required
parameter_format
string