JavaScript
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.admin.attributes.create([
{
name: 'Plan',
key: 'plan',
type: 'user'
},
{
name: 'Device',
key: 'device',
type: 'event'
}
]);from trophy import TrophyApi
client = TrophyApi(api_key='YOUR_API_KEY')
response = client.admin.attributes.create([
{
"name": "Plan",
"key": "plan",
"type": "user"
},
{
"name": "Device",
"key": "device",
"type": "event"
}
])import (
"context"
api "github.com/trophyso/trophy-go"
trophyclient "github.com/trophyso/trophy-go/client"
"github.com/trophyso/trophy-go/option"
)
client := trophyclient.NewClient(
option.WithApiKey("YOUR_API_KEY"),
)
response, err := client.Admin.Attributes.Create(context.TODO(), api.CreateAttributesRequest{})curl --request POST \
--url https://admin.trophy.so/v1/attributes \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
[
{
"name": "Plan",
"key": "plan",
"type": "user"
},
{
"name": "Device",
"key": "device",
"type": "event"
}
]
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://admin.trophy.so/v1/attributes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'name' => 'Plan',
'key' => 'plan',
'type' => 'user'
],
[
'name' => 'Device',
'key' => 'device',
'type' => 'event'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://admin.trophy.so/v1/attributes")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n {\n \"name\": \"Plan\",\n \"key\": \"plan\",\n \"type\": \"user\"\n },\n {\n \"name\": \"Device\",\n \"key\": \"device\",\n \"type\": \"event\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://admin.trophy.so/v1/attributes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"name\": \"Plan\",\n \"key\": \"plan\",\n \"type\": \"user\"\n },\n {\n \"name\": \"Device\",\n \"key\": \"device\",\n \"type\": \"event\"\n }\n]"
response = http.request(request)
puts response.read_body{
"created": [],
"issues": [
{
"index": 0,
"severity": "error",
"message": "Name not a string"
},
{
"index": 1,
"severity": "error",
"message": "Key already in use by another attribute of this type"
}
]
}{
"created": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Plan",
"key": "plan",
"type": "user"
},
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"name": "Device",
"key": "device",
"type": "event"
}
],
"issues": []
}{
"error": "<string>"
}{
"error": "<string>"
}Admin
Create attributes
Create attributes.
POST
/
attributes
JavaScript
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.admin.attributes.create([
{
name: 'Plan',
key: 'plan',
type: 'user'
},
{
name: 'Device',
key: 'device',
type: 'event'
}
]);from trophy import TrophyApi
client = TrophyApi(api_key='YOUR_API_KEY')
response = client.admin.attributes.create([
{
"name": "Plan",
"key": "plan",
"type": "user"
},
{
"name": "Device",
"key": "device",
"type": "event"
}
])import (
"context"
api "github.com/trophyso/trophy-go"
trophyclient "github.com/trophyso/trophy-go/client"
"github.com/trophyso/trophy-go/option"
)
client := trophyclient.NewClient(
option.WithApiKey("YOUR_API_KEY"),
)
response, err := client.Admin.Attributes.Create(context.TODO(), api.CreateAttributesRequest{})curl --request POST \
--url https://admin.trophy.so/v1/attributes \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
[
{
"name": "Plan",
"key": "plan",
"type": "user"
},
{
"name": "Device",
"key": "device",
"type": "event"
}
]
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://admin.trophy.so/v1/attributes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'name' => 'Plan',
'key' => 'plan',
'type' => 'user'
],
[
'name' => 'Device',
'key' => 'device',
'type' => 'event'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://admin.trophy.so/v1/attributes")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n {\n \"name\": \"Plan\",\n \"key\": \"plan\",\n \"type\": \"user\"\n },\n {\n \"name\": \"Device\",\n \"key\": \"device\",\n \"type\": \"event\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://admin.trophy.so/v1/attributes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"name\": \"Plan\",\n \"key\": \"plan\",\n \"type\": \"user\"\n },\n {\n \"name\": \"Device\",\n \"key\": \"device\",\n \"type\": \"event\"\n }\n]"
response = http.request(request)
puts response.read_body{
"created": [],
"issues": [
{
"index": 0,
"severity": "error",
"message": "Name not a string"
},
{
"index": 1,
"severity": "error",
"message": "Key already in use by another attribute of this type"
}
]
}{
"created": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Plan",
"key": "plan",
"type": "user"
},
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"name": "Device",
"key": "device",
"type": "event"
}
],
"issues": []
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Headers
The tenant identifier for multi-tenant organisations. Required when the organisation has multi-tenancy enabled. Pass your own internal customer ID for the tenant. Ignored for single-tenant organisations.
Body
application/json
Array of attributes to create. Maximum 100 attributes per request.
Required array length:
1 - 100 elementsResponse
Successful operation (no attributes created)
Was this page helpful?
⌘I