Skip to content

Update an attribute

Patch
bash
https://api.bunce.so/v1/attributes/{attribute_id}

Update an attribute.

If successful, your response includes a copy of the updated attribute entity. If there is an error with any of the parameters, it will return a 422 HTTP status code with details in an error object.

Request

Route Parameters attribute_id (string<uuid>)

Body Parameters required

name string nullableAttribute name
data_type string<text,timestamp,numeric> nullableAttribute Data Type
bash
curl --request PATCH \
  --url https://api.bunce.so/v1/attributes/018c7737-0ab2-78f7-ba75-1710dd8fe631 \
  --header 'Content-Type: application/json' \
  --header 'X-Authorization: sk_live_************************' \
  --data '{
      "name": "Birthday",
      "data_type": "text"
}'
go
import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

url := "https://api.bunce.so/v1/attributes/018c7737-0ab2-78f7-ba75-1710dd8fe631"

payload := strings.NewReader("{\n  \"name\": \"Birthday\",\n  \"data_type\": \"date\",\n}")

req, _ := http.NewRequest("PATCH", url, payload)

req.Header.Add("X-Authorization", "sk_live_************************")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res)
fmt.Println(string(body))
js
import  from 'node-fetch'

let  = 'https://api.bunce.so/v1/attributes/018c7737-0ab2-78f7-ba75-1710dd8fe631'

let  = {
  : 'PATCH',
  : {
    'X-Authorization': 'sk_live_************************',
    'Content-Type': 'application/json',
  },
  : '{"name":"Birthday", "data_type":"date"}',
}

(, )
  .then(() => .json())
  .then(() => .())
  .catch(() => .('error:' + ))
php
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{
  "name": "Birthday",
  "data_type": "date"
}');

$request->setRequestUrl('https://api.bunce.so/v1/attributes/018c7737-0ab2-78f7-ba75-1710dd8fe631');
$request->setRequestMethod('PATCH');
$request->setBody($body);

$request->setHeaders([
  'X-Authorization' => 'sk_live_************************',
  'Content-Type' => 'application/json'
]);

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
java
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.bunce.so/v1/attributes/018c7737-0ab2-78f7-ba75-1710dd8fe631"))
    .header("X-Authorization", "sk_live_************************")
    .header("Content-Type", "application/json")
    .method("PATCH", HttpRequest.BodyPublishers.ofString("{\n  \"name\": \"Birthday\",\n  \"data_type\": \"date\",\n }"))
    .build();

HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());

System.out.println(response.body());

Response

json
{
  "data": {
    "id": "018c76f4-01b8-7c6b-a54b-6b681fc78295",
    "data_type": "date",
    "name": "Birthday"
  },
  "message": "Attribute successfully updated",
  "success": true
}