Skip to main content
Access templates through a BusinessAccount or directly via the client.
account   = client.business_accounts.list.data.first
templates = account.templates
# or:
templates = client.templates(account.id)

List templates

result = templates.list
result.data  # => Array of Template objects

# Filter by status or category
result = templates.list(status: "approved")
result = templates.list(status: "approved", category: "MARKETING")
Status values: approved, pending, rejected.

Find by name

tpl = templates.find_by_name("order_confirmation")
tpl&.approved?  # => true

Retrieve a template

tpl = templates.retrieve("tpl_01hx...")
tpl.name     # => "order_confirmation"
tpl.status   # => "approved"
tpl.language # => "en_US"
tpl.category # => "UTILITY"

Create a template

tpl = templates.create(
  name:     "order_confirmation",
  category: "UTILITY",
  language: "en_US",
  components: [
    {
      type: "BODY",
      text: "Your order {{1}} has been confirmed."
    }
  ]
)
tpl.status  # => "pending"  (awaiting Meta approval)

Sync from Meta

Pulls the latest template statuses from Meta and updates your local records:
result = templates.sync
result.data  # => Array of synced Template objects

Clone a template

clone = templates.clone("tpl_01hx...")
clone.name  # => "order_confirmation_copy"

Send a test message

msg = templates.send_test(
  "tpl_01hx...",
  to: "+33699887766",
  variables: ["ORDER-123"]
)
msg.status  # => "queued"

Delete a template

templates.delete("tpl_01hx...")  # => true

Template attributes

AttributeTypeDescription
idStringWhatsRB template ID
meta_template_idStringMeta template ID
nameStringTemplate name
categoryStringUTILITY, MARKETING, AUTHENTICATION
statusStringapproved, pending, rejected
languageStringLanguage code (e.g. en_US)
header_typeStringTEXT, IMAGE, VIDEO, DOCUMENT
componentsArrayTemplate components
rejection_reasonStringReason if rejected

Status helpers

tpl.approved?  # => true
tpl.pending?   # => false
tpl.rejected?  # => false