Typescript (SDK)
import { Latitudesh } from "latitudesh-typescript-sdk";
const latitudesh = new Latitudesh({
bearer: process.env["LATITUDESH_BEARER"] ?? "",
});
async function run() {
const result = await latitudesh.elasticIps.createElasticIpBgpSession({
elasticIpId: "ueip_059EqY7kOQj8p",
createBgpSession: {
data: {
type: "bgp_sessions",
attributes: {
serverId: "sv_A05EdQp4OvKYQ",
},
},
},
});
console.log(result);
}
run();package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"github.com/latitudesh/latitudesh-go-sdk/models/components"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.ElasticIps.CreateElasticIPBgpSession(ctx, "ueip_059EqY7kOQj8p", components.CreateBgpSession{
Data: components.CreateBgpSessionData{
Type: components.CreateBgpSessionTypeBgpSessions,
Attributes: &components.CreateBgpSessionAttributes{
ServerID: "sv_A05EdQp4OvKYQ",
},
},
})
if err != nil {
log.Fatal(err)
}
if res.BgpSession != nil {
// handle response
}
}curl --request POST \
--url https://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"type": "bgp_sessions",
"attributes": {
"server_id": "sv_A05EdQp4OvKYQ"
}
}
}
'import requests
url = "https://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions"
payload = { "data": {
"type": "bgp_sessions",
"attributes": { "server_id": "sv_A05EdQp4OvKYQ" }
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: {type: 'bgp_sessions', attributes: {server_id: 'sv_A05EdQp4OvKYQ'}}})
};
fetch('https://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions', 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.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions",
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([
'data' => [
'type' => 'bgp_sessions',
'attributes' => [
'server_id' => 'sv_A05EdQp4OvKYQ'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"type\": \"bgp_sessions\",\n \"attributes\": {\n \"server_id\": \"sv_A05EdQp4OvKYQ\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"type\": \"bgp_sessions\",\n \"attributes\": {\n \"server_id\": \"sv_A05EdQp4OvKYQ\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "bgps_w49QDB9PqagKb",
"type": "bgp_sessions",
"attributes": {
"status": "pending",
"status_message": null,
"server_ip": null,
"asn": null,
"created_at": null,
"server": {
"id": "sv_A05EdQp4OvKYQ",
"hostname": "para-bgp-3",
"primary_ipv4": "162.43.189.161",
"operating_system": "ubuntu_24_04_x64_lts"
},
"region": {
"id": "reg_qOxWMz15VGAwd",
"name": "United States",
"location": {
"id": "loc_Yb7VpP53OjxEr",
"name": "Los Angeles 2",
"slug": "LAX2"
}
}
}
}
}Elastic Ips
Create a BGP session
Announce an elastic IP from a server over BGP
POST
/
elastic_ips
/
{elastic_ip_id}
/
bgp_sessions
Typescript (SDK)
import { Latitudesh } from "latitudesh-typescript-sdk";
const latitudesh = new Latitudesh({
bearer: process.env["LATITUDESH_BEARER"] ?? "",
});
async function run() {
const result = await latitudesh.elasticIps.createElasticIpBgpSession({
elasticIpId: "ueip_059EqY7kOQj8p",
createBgpSession: {
data: {
type: "bgp_sessions",
attributes: {
serverId: "sv_A05EdQp4OvKYQ",
},
},
},
});
console.log(result);
}
run();package main
import(
"context"
"os"
latitudeshgosdk "github.com/latitudesh/latitudesh-go-sdk"
"github.com/latitudesh/latitudesh-go-sdk/models/components"
"log"
)
func main() {
ctx := context.Background()
s := latitudeshgosdk.New(
latitudeshgosdk.WithSecurity(os.Getenv("LATITUDESH_BEARER")),
)
res, err := s.ElasticIps.CreateElasticIPBgpSession(ctx, "ueip_059EqY7kOQj8p", components.CreateBgpSession{
Data: components.CreateBgpSessionData{
Type: components.CreateBgpSessionTypeBgpSessions,
Attributes: &components.CreateBgpSessionAttributes{
ServerID: "sv_A05EdQp4OvKYQ",
},
},
})
if err != nil {
log.Fatal(err)
}
if res.BgpSession != nil {
// handle response
}
}curl --request POST \
--url https://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"type": "bgp_sessions",
"attributes": {
"server_id": "sv_A05EdQp4OvKYQ"
}
}
}
'import requests
url = "https://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions"
payload = { "data": {
"type": "bgp_sessions",
"attributes": { "server_id": "sv_A05EdQp4OvKYQ" }
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: {type: 'bgp_sessions', attributes: {server_id: 'sv_A05EdQp4OvKYQ'}}})
};
fetch('https://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions', 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.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions",
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([
'data' => [
'type' => 'bgp_sessions',
'attributes' => [
'server_id' => 'sv_A05EdQp4OvKYQ'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"type\": \"bgp_sessions\",\n \"attributes\": {\n \"server_id\": \"sv_A05EdQp4OvKYQ\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/elastic_ips/{elastic_ip_id}/bgp_sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"type\": \"bgp_sessions\",\n \"attributes\": {\n \"server_id\": \"sv_A05EdQp4OvKYQ\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "bgps_w49QDB9PqagKb",
"type": "bgp_sessions",
"attributes": {
"status": "pending",
"status_message": null,
"server_ip": null,
"asn": null,
"created_at": null,
"server": {
"id": "sv_A05EdQp4OvKYQ",
"hostname": "para-bgp-3",
"primary_ipv4": "162.43.189.161",
"operating_system": "ubuntu_24_04_x64_lts"
},
"region": {
"id": "reg_qOxWMz15VGAwd",
"name": "United States",
"location": {
"id": "loc_Yb7VpP53OjxEr",
"name": "Los Angeles 2",
"slug": "LAX2"
}
}
}
}
}Was this page helpful?
⌘I