Skip to main content

Phrases

Phrases are the core translation units in Multilocale. Each phrase has a key, a value, and a language.

Phrase Object

{
"_id": "507f1f77bcf86cd799439011",
"key": "welcome_message",
"value": "Welcome to our app!",
"language": "en",
"organizationId": "507f1f77bcf86cd799439012",
"projects": ["my-app"],
"projectsIds": ["507f1f77bcf86cd799439013"],
"googleTranslate": false,
"creationTime": "2024-01-15T10:30:00.000Z",
"lastEditTime": "2024-01-15T10:30:00.000Z"
}

List Phrases

Retrieve phrases matching the given filters.

GET /api/phrases

Authentication: Token or organizationId query parameter

Query Parameters

ParameterTypeDescription
organizationIdstringFilter by organization (alternative to token auth)
keystringFilter by exact key (URL-encoded)
languagestringFilter by language code
projectstringFilter by project name
fieldsstringComma-separated list of fields to return

Example

# Get all English phrases for a project
curl "https://api.multilocale.com/api/phrases?project=my-app&language=en" \
-H "Authorization: Token <base64-token>"

# Get specific fields only
curl "https://api.multilocale.com/api/phrases?project=my-app&fields=key,value,language" \
-H "Authorization: Token <base64-token>"

# Public access with organizationId
curl "https://api.multilocale.com/api/phrases?organizationId=abc123&project=my-app&language=en"

Response

[
{
"key": "welcome_message",
"value": "Welcome!",
"language": "en"
},
{
"key": "goodbye",
"value": "Goodbye!",
"language": "en"
}
]

Create Phrases

Create one or more phrases.

POST /api/phrases

Authentication: Token required

Body

A single phrase object or an array of phrase objects:

[
{
"_id": "unique-id-1",
"key": "welcome_message",
"value": "Welcome!",
"language": "en",
"projects": ["my-app"],
"projectsIds": ["project-id"]
},
{
"_id": "unique-id-2",
"key": "welcome_message",
"value": "Bienvenido!",
"language": "es",
"projects": ["my-app"],
"projectsIds": ["project-id"]
}
]

Response

Returns the created phrase(s) in the same shape as the input (single object or array).

Update a Phrase

Update an existing phrase.

PUT /api/phrases/:phraseId

Authentication: Token required

Body

{
"_id": "507f1f77bcf86cd799439011",
"key": "welcome_message",
"value": "Welcome to our updated app!",
"language": "en"
}

Response

Returns the updated phrase object.

Delete Phrases

Delete all phrases matching a key and project.

DELETE /api/phrases

Authentication: Token required

Query Parameters

ParameterTypeRequiredDescription
keystringYesThe phrase key (URL-encoded)
projectstringYesThe project name

Example

curl -X DELETE "https://api.multilocale.com/api/phrases?key=old_key&project=my-app" \
-H "Authorization: Token <base64-token>"

Response

Returns an array of the deleted phrases, or 404 if no matching phrases were found.