Create a variation
POST/v1/projects/{projectId}/variations
Creates a variation whose head is fromVersionId (any version of this project), or the head of fromVariation, or main's head when both are left out; the project must have a version. name is 1 to 100 characters: letters, digits, '-', '_' or '.', starting with a letter or digit, kept in lower case. A name the project already has is 409 variation_exists; past 100 variations, main included, 409 variation_limit. A fromVersionId larger than the plan's project size and than every head of the project, such as a render's own version made larger by its replacements, is 403 project_too_large. Send an Idempotency-Key header (1 to 200 characters) to make retries safe: for 24 hours the same request with the same key answers with what the first one made, with the header Idempotent-Replayed: true; the same key with a different request is 422 idempotency_key_reused while what the first one made exists, and while the first request is still running 409 idempotency_key_in_use, except that the retry of a ZIP import waits for that import, as the first request does. A request that failed made nothing, so it can be sent again with its key.
Request
curl -s -X POST $BLITFRAME/projects/c1edf0fb-045f-4c8a-af93-6d5e6e554334/variations \
-H "Authorization: Bearer $BLITFRAME_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 05a54079-a200-0def-96cc-7bc9e4c2543a" \
-d '{"name": "spanish", "fromVariation": "main"}'
import os, requests
response = requests.post(
f"{os.environ['BLITFRAME']}/projects/c1edf0fb-045f-4c8a-af93-6d5e6e554334/variations",
headers={
"Authorization": f"Bearer {os.environ['BLITFRAME_API_KEY']}",
"Idempotency-Key": "05a54079-a200-0def-96cc-7bc9e4c2543a",
},
json={"name": "spanish", "fromVariation": "main"},
)
print(response.json())
const response = await fetch(`${process.env.BLITFRAME}/projects/c1edf0fb-045f-4c8a-af93-6d5e6e554334/variations`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BLITFRAME_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": "05a54079-a200-0def-96cc-7bc9e4c2543a",
},
body: JSON.stringify({ name: "spanish", fromVariation: "main" }),
});
console.log(await response.json());
<?php
$request = curl_init(getenv("BLITFRAME") . "/projects/c1edf0fb-045f-4c8a-af93-6d5e6e554334/variations");
curl_setopt_array($request, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("BLITFRAME_API_KEY"),
"Content-Type: application/json",
"Idempotency-Key: 05a54079-a200-0def-96cc-7bc9e4c2543a",
],
CURLOPT_POSTFIELDS => '{"name": "spanish", "fromVariation": "main"}',
]);
$response = curl_exec($request);
echo $response;
require "net/http"
uri = URI(ENV["BLITFRAME"] + '/projects/c1edf0fb-045f-4c8a-af93-6d5e6e554334/variations')
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer " + ENV["BLITFRAME_API_KEY"]
request["Content-Type"] = "application/json"
request['Idempotency-Key'] = '05a54079-a200-0def-96cc-7bc9e4c2543a'
request.body = '{"name": "spanish", "fromVariation": "main"}'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
puts response.body
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"name": "spanish", "fromVariation": "main"}`)
request, err := http.NewRequest("POST", os.Getenv("BLITFRAME")+"/projects/c1edf0fb-045f-4c8a-af93-6d5e6e554334/variations", body)
if err != nil {
panic(err)
}
request.Header.Set("Authorization", "Bearer "+os.Getenv("BLITFRAME_API_KEY"))
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Idempotency-Key", "05a54079-a200-0def-96cc-7bc9e4c2543a")
response, err := http.DefaultClient.Do(request)
if err != nil {
panic(err)
}
defer response.Body.Close()
text, _ := io.ReadAll(response.Body)
fmt.Println(string(text))
}
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post,
Environment.GetEnvironmentVariable("BLITFRAME") + "/projects/c1edf0fb-045f-4c8a-af93-6d5e6e554334/variations");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("BLITFRAME_API_KEY"));
request.Headers.Add("Idempotency-Key", "05a54079-a200-0def-96cc-7bc9e4c2543a");
request.Content = new StringContent(
"""
{"name": "spanish", "fromVariation": "main"}
""", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
var request = HttpRequest.newBuilder(URI.create(System.getenv("BLITFRAME") + "/projects/c1edf0fb-045f-4c8a-af93-6d5e6e554334/variations"))
.header("Authorization", "Bearer " + System.getenv("BLITFRAME_API_KEY"))
.header("Content-Type", "application/json")
.header("Idempotency-Key", "05a54079-a200-0def-96cc-7bc9e4c2543a")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{"name": "spanish", "fromVariation": "main"}
"""))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Path parameters
projectIdstring (uuid)required
Headers
AuthorizationBearer Blitframe API keyrequiredAPI key from the developer console.
Idempotency-KeystringOptional. A unique key you choose for this one request, 1 to 200 characters, such as a new UUID. Send the same key again only to retry this request after a lost answer: the retry answers with what the first one made instead of doing it again. Use a new key for every other request; the key in the samples is only an example.
Body
application/json · required · CreateVariationRequest
namestringrequiredfromVersionIdstring (uuid) or nullfromVariationstring or null
Responses
- 201 Created
application/json · VariationDto
namestringheadVersionIdstring (uuid) or nullcreatedAtstring (date-time)
Errors
- 400 Bad Request
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 409 Conflict
- 422 Unprocessable Entity
- 429 Too Many Requests
application/json · ErrorResponse
errorApiErrorApiError fields
codestringmessagestring
Errors lists the error codes and says when to retry.