Edit a spreadsheet
curl --request PATCH \
--url https://api.custral.com/v1/spreadsheets/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"operations": [
{
"kind": "set_values",
"cell": "B2",
"values": [
[
"<string>"
]
],
"sheet": "<string>"
}
]
}
'import requests
url = "https://api.custral.com/v1/spreadsheets/{id}"
payload = { "operations": [
{
"kind": "set_values",
"cell": "B2",
"values": [["<string>"]],
"sheet": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
operations: [{kind: 'set_values', cell: 'B2', values: [['<string>']], sheet: '<string>'}]
})
};
fetch('https://api.custral.com/v1/spreadsheets/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.custral.com/v1/spreadsheets/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'operations' => [
[
'kind' => 'set_values',
'cell' => 'B2',
'values' => [
[
'<string>'
]
],
'sheet' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.custral.com/v1/spreadsheets/{id}"
payload := strings.NewReader("{\n \"operations\": [\n {\n \"kind\": \"set_values\",\n \"cell\": \"B2\",\n \"values\": [\n [\n \"<string>\"\n ]\n ],\n \"sheet\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.custral.com/v1/spreadsheets/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"operations\": [\n {\n \"kind\": \"set_values\",\n \"cell\": \"B2\",\n \"values\": [\n [\n \"<string>\"\n ]\n ],\n \"sheet\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.custral.com/v1/spreadsheets/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"operations\": [\n {\n \"kind\": \"set_values\",\n \"cell\": \"B2\",\n \"values\": [\n [\n \"<string>\"\n ]\n ],\n \"sheet\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"sheets": [
{
"title": "<string>",
"rows": [
[
"<unknown>"
]
],
"formulas": {}
}
]
},
"reqId": "req_2a1f9c8e7b6d5"
}Spreadsheets
Edit a spreadsheet
Set a block of values, append rows, clear a range, add or rename a tab. Operations apply in order and all or nothing; the edit lands live in any open editor. A page of another type returns 404 spreadsheet_not_found; a caller who can only view it gets insufficient_permissions. Requires scope: documents:write.
PATCH
/
v1
/
spreadsheets
/
{id}
Edit a spreadsheet
curl --request PATCH \
--url https://api.custral.com/v1/spreadsheets/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"operations": [
{
"kind": "set_values",
"cell": "B2",
"values": [
[
"<string>"
]
],
"sheet": "<string>"
}
]
}
'import requests
url = "https://api.custral.com/v1/spreadsheets/{id}"
payload = { "operations": [
{
"kind": "set_values",
"cell": "B2",
"values": [["<string>"]],
"sheet": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
operations: [{kind: 'set_values', cell: 'B2', values: [['<string>']], sheet: '<string>'}]
})
};
fetch('https://api.custral.com/v1/spreadsheets/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.custral.com/v1/spreadsheets/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'operations' => [
[
'kind' => 'set_values',
'cell' => 'B2',
'values' => [
[
'<string>'
]
],
'sheet' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.custral.com/v1/spreadsheets/{id}"
payload := strings.NewReader("{\n \"operations\": [\n {\n \"kind\": \"set_values\",\n \"cell\": \"B2\",\n \"values\": [\n [\n \"<string>\"\n ]\n ],\n \"sheet\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.custral.com/v1/spreadsheets/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"operations\": [\n {\n \"kind\": \"set_values\",\n \"cell\": \"B2\",\n \"values\": [\n [\n \"<string>\"\n ]\n ],\n \"sheet\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.custral.com/v1/spreadsheets/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"operations\": [\n {\n \"kind\": \"set_values\",\n \"cell\": \"B2\",\n \"values\": [\n [\n \"<string>\"\n ]\n ],\n \"sheet\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"sheets": [
{
"title": "<string>",
"rows": [
[
"<unknown>"
]
],
"formulas": {}
}
]
},
"reqId": "req_2a1f9c8e7b6d5"
}Authorizations
A Custral API key, created in Settings → Developers → Applications, sent as Authorization: Bearer sk_…. The X-Api-Key header is also accepted and takes precedence. Use a secret key (sk_…) from your server; a publishable key (pk_…) may hold only objects:read and usage:write. Never expose a secret key in a browser.
Path Parameters
Body
application/json
Was this page helpful?