0

Create a git token

by
Published Oct 17, 2025

Create a new git token to be used as a git provider by a service

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create a git token
4
 * Create a new git token to be used as a git provider by a service
5
 */
6
export async function main(auth: RT.Qovery, organizationId: string, body: Body) {
7
	const url = new URL(`https://api.qovery.com/organization/${organizationId}/gitToken`)
8

9
	const response = await fetch(url, {
10
		method: 'POST',
11
		headers: {
12
			'Content-Type': 'application/json',
13
			Authorization: 'Token ' + auth.apiKey
14
		},
15
		body: JSON.stringify(body)
16
	})
17
	if (!response.ok) {
18
		const text = await response.text()
19
		throw new Error(`${response.status} ${text}`)
20
	}
21
	return await response.json()
22
}
23

24
/* eslint-disable */
25
/**
26
 * This file was automatically generated by json-schema-to-typescript.
27
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
28
 * and run json-schema-to-typescript to regenerate this file.
29
 */
30

31
export interface Body {
32
	name: string
33
	description?: string
34
	type: 'BITBUCKET' | 'GITHUB' | 'GITLAB'
35
	/**
36
	 * The token from your git provider side
37
	 */
38
	token: string
39
	/**
40
	 * Mandatory only for BITBUCKET git provider, to allow us to fetch repositories at creation/edition of a service
41
	 */
42
	workspace?: string
43
	/**
44
	 * custom git api url for the given git provider/type.
45
	 * I.e: Self-hosted version of Gitlab
46
	 */
47
	git_api_url?: string
48
	[k: string]: unknown
49
}
50