Quickstart
The simplest call that confirms your token reaches the segmentation rules API lists the rules already in your organization:200 response with a content array means you are connected and authorized. The base host depends on your region, and the token is set up in Prerequisites below.
Prerequisites
The two rule formats
Phrase TMS accepts custom segmentation rules in two formats:
Segmentation determines where segment boundaries fall (typically at sentence ends), which directly affects translation memory (TM) match quality. A job (a file sent for translation) segmented differently than the TM it is leveraged against will get lower or no matches, so the rules that shipped with a job need to match the rules behind its TM.
Phrase’s SRX rules are character-based: only a single character can act as the segment separator. A group of characters (for example a tag like
<p>) cannot be used as a separator.SRX 2.0 structure
An SRX document has aheader (global options) and a body (the rules):
header:cascadecontrols whether more than one matchinglanguagemapcan apply its rules in sequence (yes) or only the first match is used (no, the SRX 1.0-compatible default).segmentsubflowscontrols whether text inside sub-flows (for example footnotes) is segmented too.formathandlecontrols whether inline formatting codes at the start, end, or isolated position of a segment are included in it.languagerules: one or more named groups ofruleelements, evaluated top to bottom. Each rule is eitherbreak="yes"(this is a valid segment boundary) orbreak="no"(suppress a break here, even if a later rule would otherwise break). A rule matches when the text immediately before the candidate break point matchesbeforebreakand the text immediately after it matchesafterbreak.maprules: maps a language code pattern (languagemap languagepattern, a regular expression like.*or(DE|de).*) to one of the namedlanguagerulegroups, so different languages can use different rule sets.
Worked example: upload a language-specific exception rule
Say German jobs keep breaking at “Co.” in company names like “GmbH & Co. KG”. The fix is a German-only SRX file that suppresses the break after “Co.”, then uploading it as a segmentation rule for the German locale (the language-plus-region code that identifies a translation direction, likede or de-AT).
1. Write the SRX file. Add a languagerule group with the break="no" rule listed before the general break="yes" rule, so it takes precedence at that position, and map it to German locales:
POST /api2/v1/segmentationRules streams the file as the request body and takes a segRule header carrying the rule’s metadata as a JSON object (name, locale, primary, filename):
201 response returns the created rule, including the uid you use to get, edit, export, or replace it later:
primary to true to make this the default rule for the German locale across the organization. New rules take effect at job import time, so re-import affected jobs for the change to apply.
When the upload fails
For the full list of response codes, see Error handling and limits.Managing rules via the API
When listing rules, the
language and languages query parameters are mutually exclusive; passing both returns 400 Bad Request. The same actions are also available in the TMS web UI under Project Settings → Segmentation, where default rules can be exported as a starting point and custom rules uploaded as primary or secondary rule sets.Rate limits
The segmentation rules endpoints share the standard Phrase TMS limit of 6,000 requests per minute for logged-in users, and return429 Too Many Requests when it is exceeded. Back off and retry rather than looping on the error. See Handling API rate limits for the details.
Troubleshooting
If a call keeps failing after the fixes above, check the current Phrase TMS Limits and the Segmentation Rules (TMS) support article for the source-of-truth values and UI behavior. For account-specific problems, contact Phrase support; for help writing the API calls themselves, an AI tool with this page in context is often faster.Next steps
Segmentation Rules API
Full request and response reference for every segmentation rules endpoint.
SRX 2.0 specification
The complete SRX standard from the Okapi Framework, for advanced rule authoring.