0

Activate a Repo Sync

by
Published Oct 17, 2025

Activate a deactivated Repo Sync. Active syncs can be used to import and export translations, and imports to Phrase are automatically triggered by pushes to the repository, if configured.

Script phrase Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Phrase = {
3
	token: string
4
	baseUrl: string
5
}
6
/**
7
 * Activate a Repo Sync
8
 * Activate a deactivated Repo Sync. Active syncs can be used to import and export translations,
9
and imports to Phrase are automatically triggered by pushes to the repository, if configured.
10
 */
11
export async function main(auth: Phrase, account_id: string, id: string) {
12
	const url = new URL(`${auth.baseUrl}/accounts/${account_id}/repo_syncs/${id}/activate`)
13

14
	const response = await fetch(url, {
15
		method: 'POST',
16
		headers: {
17
			Authorization: 'ApiToken ' + auth.token
18
		},
19
		body: undefined
20
	})
21
	if (!response.ok) {
22
		const text = await response.text()
23
		throw new Error(`${response.status} ${text}`)
24
	}
25
	return await response.json()
26
}
27