Create an SMS keyword rule
POST
/v1/sms/keyword-rules
const rule = await bird.smsKeywordRules.create({
operation: "stop",
country: "NL",
reply: "You are unsubscribed from MyBrand. Reply START to resume.",
});
// effective_keywords is Bird's set plus any of your own.
console.log(rule.id, rule.effective_keywords);rule = client.sms_keyword_rules.create(
operation="stop",
country="NL",
reply="You are unsubscribed from MyBrand. Reply START to resume.",
)
# effective_keywords is Bird's set plus any of your own.
print(rule.id, rule.effective_keywords)rule, err := client.SmsKeywordRules.Create(context.Background(), bird.SmsKeywordRulesCreateParams{
Operation: bird.SMSKeywordOperationStop,
Country: bird.Value("NL"),
Reply: bird.Value("You are unsubscribed from MyBrand. Reply START to resume."),
})
if err != nil {
log.Fatal(err)
}
// EffectiveKeywords is Bird's set plus any of your own.
fmt.Println(rule.Id, *rule.EffectiveKeywords)$rule = $bird->smsKeywordRules->create(
(new SMSKeywordRuleCreate())
->setOperation('stop')
->setCountry('NL')
->setReply('You are unsubscribed from MyBrand. Reply START to resume.'),
);
// getEffectiveKeywords() is Bird's set plus any of your own.
echo $rule->getId(), ' ', implode(',', $rule->getEffectiveKeywords() ?? []);bird sms keyword-rules create --body-file - <<'JSON'
{
"confirmed_self_managed": true,
"country": "NL",
"keywords": [
"pizza",
"menu"
],
"language": "fr",
"number": "+18005551234",
"operation": "stop",
"reply": "You have been unsubscribed and will receive no further messages."
}
JSONcurl -X POST "https://us1.platform.bird.com/v1/sms/keyword-rules" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operation": "stop",
"country": "NL",
"language": "fr",
"number": "+18005551234",
"keywords": [
"pizza",
"menu"
],
"reply": "You have been unsubscribed and will receive no further messages.",
"confirmed_self_managed": true
}'Creates a keyword rule for your workspace. Use it to replace the reply Bird sends for opt-out, opt-in or help in one country, or to add campaign keywords of your own with custom.
Your rule takes precedence over Bird's default for the same country, and keeps Bird's keywords unless you add more, including keywords Bird adds later. What an opt-out or opt-in keyword does cannot be changed, so a rule that binds one of them to a different operation is rejected.
请求载荷
operation
string
必填
What Bird does when an inbound message matches one of the rule's keywords. "stop" unsubscribes the sender, "start" resubscribes them, and "help" replies with your support information. Those three are what carriers and regulators expect a number to honour, so Bird ships keywords for them wherever its catalogue covers the country, and you cannot change what they do. "custom" carries no built-in behaviour: it matches keywords you choose and sends the reply you write, which is how campaign keywords like PIZZA are handled. Open enum: additional operations may be added over time, so treat an unrecognized value as a future operation rather than an error.
Possible values (may grow over time): stop, start, help, custom
country
nullable string
The country this rule applies in, as an ISO 3166-1 alpha-2 code. It matches a message two ways: one received on any of your numbers in this country, and one sent by a subscriber whose own number is in it, wherever they text you. A rule for the country a message arrives in is always preferred over a rule for the country its sender is in, and both are preferred over Bird's own keywords. To confine a rule to one of your numbers, set number instead. Required for stop, start and help, because those replace what Bird ships for one country and a worldwide rule would replace every country's. Omit it only for custom, which then applies everywhere you send. Derived from number when you supply an E.164 number and leave this out; a short code carries no country, so a rule for one must name it.
language
nullable string
Which language this rule replaces, in countries where Bird ships keywords in more than one. Required there and rejected elsewhere. Listing the country's rules shows whether it applies and which languages are available.
number
nullable string
Narrows the rule to one number you hold, in E.164 format or as a short code. Omit to cover every number you hold in the country. The number must be one of yours and able to receive messages.
keywords
array of string
Extra keywords to match, on top of the ones Bird already ships for this operation and country. Omit to keep Bird's keywords and change only the reply, including keywords Bird adds later. You cannot remove one of Bird's keywords, and a keyword Bird has bound to another operation cannot be reused here. Required for custom, which inherits none.
reply
nullable string
The message to send back when a keyword matches. Set it to null together with confirmed_self_managed to send nothing at all.
confirmed_self_managed
boolean
Set this with reply: null to confirm you send this reply from your own system, which switches Bird's auto-reply off for the rule. Required to send no reply, and rejected when a reply is given, so the two can never disagree.
响应载荷
id
string
必填
Identifier of a keyword rule. An sks_ id is one of Bird's defaults, which you can read but not change; an skw_ id is a rule your workspace created.
scope
string
必填
Whether the rule is one of Bird's defaults (system) or one your workspace created (workspace). A workspace rule takes precedence over Bird's default for the same country, so it is how you replace a reply without losing the keywords Bird ships.
Possible values: system, workspace
operation
string
必填
What Bird does when an inbound message matches one of the rule's keywords. "stop" unsubscribes the sender, "start" resubscribes them, and "help" replies with your support information. Those three are what carriers and regulators expect a number to honour, so Bird ships keywords for them wherever its catalogue covers the country, and you cannot change what they do. "custom" carries no built-in behaviour: it matches keywords you choose and sends the reply you write, which is how campaign keywords like PIZZA are handled. Open enum: additional operations may be added over time, so treat an unrecognized value as a future operation rather than an error.
Possible values (may grow over time): stop, start, help, custom
country
nullable string
The country the rule applies in, as an ISO 3166-1 alpha-2 code. A rule for NL covers messages received on your Dutch numbers, and messages from a subscriber whose own number is Dutch whichever of your numbers they text. A rule for the country a message arrives in wins over a rule for the country its sender is in, and both win over Bird's own keywords; number confines a rule to one number. Null means the rule applies worldwide, which is allowed for custom operations only.
language
nullable string
The language this rule covers, in countries where Bird ships keywords in more than one. Canada has separate English and French rules, so a Canadian rule names which one it replaces and the other keeps Bird's reply. Null in countries with a single set.
number
nullable string
Narrows the rule to one of your numbers in E.164 format, instead of every number you hold in the country. Null means it applies to all of them.
keywords
array of string
必填
The keywords this rule adds. For one of Bird's defaults this is the full set Bird ships. For a rule you created it is only what you added on top. It never restates or removes Bird's keywords, so effective_keywords is what actually matches.
effective_keywords
array of string
必填
Every keyword that matches this rule: Bird's keywords for the same operation, country and language, plus the ones you added. This is what an inbound message is compared against. Keywords Bird adds later join it without you changing anything.
reply
nullable string
The message sent back when one of the keywords matches. Null when the auto-reply is switched off, which reply_disabled_at distinguishes from a rule that has not been given one.
reply_suffix
nullable string
Text appended to your reply that you cannot change: the rates and opt-out wording carriers require on a help response. Your reply is sent in front of it, and both count against the length a single message allows. Null when the operation carries none.
reply_disabled_at
nullable string
When the auto-reply for this rule was switched off, or null if it is on. Switching it off records that you send this reply from your own system, which is what Bird points to if a carrier asks why no reply went out.
mandatory
boolean
必填
Whether what this operation does is fixed. When true you can change the reply but not the behaviour. An opt-out keyword always unsubscribes the sender, whichever rule matched it, because carriers and regulators require it.
created_at
string
必填
When the rule was created.
updated_at
string
必填
When the rule was last changed. On one of Bird's defaults this is when Bird last changed the keywords or the reply for that country.