Update 2FA Method
curl --request PUT \
--url https://console.vast.ai/api/v0/tfa/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tfa_method_id": 3,
"tfa_method": "sms",
"label": "Work Phone",
"is_primary": true
}
'import requests
url = "https://console.vast.ai/api/v0/tfa/update"
payload = {
"tfa_method_id": 3,
"tfa_method": "sms",
"label": "Work Phone",
"is_primary": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({tfa_method_id: 3, tfa_method: 'sms', label: 'Work Phone', is_primary: true})
};
fetch('https://console.vast.ai/api/v0/tfa/update', 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://console.vast.ai/api/v0/tfa/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'tfa_method_id' => 3,
'tfa_method' => 'sms',
'label' => 'Work Phone',
'is_primary' => true
]),
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://console.vast.ai/api/v0/tfa/update"
payload := strings.NewReader("{\n \"tfa_method_id\": 3,\n \"tfa_method\": \"sms\",\n \"label\": \"Work Phone\",\n \"is_primary\": true\n}")
req, _ := http.NewRequest("PUT", 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.put("https://console.vast.ai/api/v0/tfa/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"tfa_method_id\": 3,\n \"tfa_method\": \"sms\",\n \"label\": \"Work Phone\",\n \"is_primary\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.vast.ai/api/v0/tfa/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tfa_method_id\": 3,\n \"tfa_method\": \"sms\",\n \"label\": \"Work Phone\",\n \"is_primary\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"msg": "2FA method updated",
"method": {
"id": 3,
"method": "sms",
"label": "Work Phone",
"is_primary": true,
"phone_number": "******5678",
"totp_secret": null
}
}{
"error": "<string>",
"msg": "<string>"
}{
"error": "<string>",
"msg": "<string>"
}{
"error": "<string>",
"msg": "<string>"
}Accounts
Update 2FA Method
Updates a 2FA method’s label or primary status for the authenticated user.
PUT
/
api
/
v0
/
tfa
/
update
Update 2FA Method
curl --request PUT \
--url https://console.vast.ai/api/v0/tfa/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tfa_method_id": 3,
"tfa_method": "sms",
"label": "Work Phone",
"is_primary": true
}
'import requests
url = "https://console.vast.ai/api/v0/tfa/update"
payload = {
"tfa_method_id": 3,
"tfa_method": "sms",
"label": "Work Phone",
"is_primary": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({tfa_method_id: 3, tfa_method: 'sms', label: 'Work Phone', is_primary: true})
};
fetch('https://console.vast.ai/api/v0/tfa/update', 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://console.vast.ai/api/v0/tfa/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'tfa_method_id' => 3,
'tfa_method' => 'sms',
'label' => 'Work Phone',
'is_primary' => true
]),
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://console.vast.ai/api/v0/tfa/update"
payload := strings.NewReader("{\n \"tfa_method_id\": 3,\n \"tfa_method\": \"sms\",\n \"label\": \"Work Phone\",\n \"is_primary\": true\n}")
req, _ := http.NewRequest("PUT", 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.put("https://console.vast.ai/api/v0/tfa/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"tfa_method_id\": 3,\n \"tfa_method\": \"sms\",\n \"label\": \"Work Phone\",\n \"is_primary\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.vast.ai/api/v0/tfa/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tfa_method_id\": 3,\n \"tfa_method\": \"sms\",\n \"label\": \"Work Phone\",\n \"is_primary\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"msg": "2FA method updated",
"method": {
"id": 3,
"method": "sms",
"label": "Work Phone",
"is_primary": true,
"phone_number": "******5678",
"totp_secret": null
}
}{
"error": "<string>",
"msg": "<string>"
}{
"error": "<string>",
"msg": "<string>"
}{
"error": "<string>",
"msg": "<string>"
}Authorizations
API key must be provided in the Authorization header
Body
application/json
ID of the 2FA method to update; preferred over tfa_method when multiple methods of the same type exist
Example:
3
Method type to update; used when tfa_method_id is not provided
Available options:
sms, totp Example:
"sms"
User-friendly name for this method (max 30 characters), e.g. 'Work Phone'
Example:
"Work Phone"
Set to true to make this the preferred default method; set to false to unset it
Example:
true
⌘I