Create a repository push remote - Spacefast Docs
Create a repository push remote
Creates a signed Git remote for pushing a Space’s files, and creates the hosted connection when the Space has none. Returns clone and push URLs that expire. An unclaimed Space may call this with its claim token; any other credential needs both spaces:write and spaces:read.
POST /v1/spaces/{spaceId}/source/push-remote
Authorization
Authorization Bearer token · header required
Authorization: Bearer <key> with the Space key (sfc_ prefix) of an unclaimed Space. The same key is the fragment of the claim URL and the token in the Space's /__/ <key> sign-in URL.
or
Authorization Bearer token · header required
Authorization: Bearer <token> with an API key (sfa_ prefix), an OAuth access token, a session token, or a Space machine credential (sfm_ prefix).
or
Authorization OAuth2 access token · header required
OAuth 2.0 with Spacefast scopes. People use the authorization code flow; machines use client credentials.
Scopes:
spaces:writespaces:read
Path parameters
spaceIdstring required
Request body
required application/json
ttlSecondsinteger (max 86400)readOnlyRefsstring[] (max items 25)
Responses
200 Response for status 200
{
"$schema": "string<uri>",
"data": {
"repositoryConnection": {
"id": "string",
"spaceId": "string",
"provider": "github",
"connectionType": "connected",
"repositoryId": "string",
"installationId": null,
"cloneUrlConfigured": false,
"upstreamUrlConfigured": false,
"repositoryName": "string",
"repositoryFullName": "string",
"defaultBranch": "string",
"productionBranch": "string",
"credentialConfigured": true,
"autoDeployProduction": true,
"autoDeployPreviews": true,
"buildSettings": {
"rootDirectory": null,
"installDirectory": null,
"installCommand": null,
"buildCommand": null,
"outputDirectory": null,
"ignoredBuildCommand": null,
"frameworkPreset": null,
"platformPreset": null,
"allowUnsupportedPlatformFeatures": false,
"timeoutSeconds": 900
},
"syncStatus": "idle",
"providerAccessStatus": "active",
"providerAccessError": null,
"lastSyncedAt": "2019-08-24T14:15:22Z",
"lastSyncError": "string",
"syncRunId": "string",
"connectedUserId": "string",
"createdAt": "2019-08-24T14:15:22Z",
"updatedAt": "2019-08-24T14:15:22Z"
},
"remote": {
"cloneUrl": "string",
"pushUrl": "string",
"expiresInSeconds": 9007199254740991,
"readOnlyRefs": ["string"]
}
}
}
Error Handling
When an error occurs, the response will include:
{
"$schema": "string<uri>",
"type": "string",
"title": "string",
"status": -9007199254740991,
"detail": "string",
"code": "string",
"pointer": "string",
"details": {
"property1": null,
"property2": null
},
"suggestions": ["string"],
"next": ["string"],
"requestId": "string"
}
Example cURL Command
curl -X POST "https://api.spacefast.com/v1/spaces/string/source/push-remote" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"ttlSeconds": 86400, "readOnlyRefs": ["string"]}'
Example JavaScript Code
const response = await fetch("https://api.spacefast.com/v1/spaces/string/source/push-remote", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: "{\n \"ttlSeconds\": 86400,\n \"readOnlyRefs\": [\n \"string\"\n ]\n}"
});
Example Python Code
import requests
response = requests.post(
"https://api.spacefast.com/v1/spaces/string/source/push-remote",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
data="{\n \"ttlSeconds\": 86400,\n \"readOnlyRefs\": [\n \"string\"\n ]\n}",
)