Create User Token
curl --request POST \
--url https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expires_at": "2023-11-07T05:31:56Z",
"expiration_tolerance_months": 0,
"send_token_email": true
}
'import requests
url = "https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token"
payload = {
"expires_at": "2023-11-07T05:31:56Z",
"expiration_tolerance_months": 0,
"send_token_email": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expires_at: '2023-11-07T05:31:56Z',
expiration_tolerance_months: 0,
send_token_email: true
})
};
fetch('https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token', 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://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token",
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([
'expires_at' => '2023-11-07T05:31:56Z',
'expiration_tolerance_months' => 0,
'send_token_email' => 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://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token"
payload := strings.NewReader("{\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"expiration_tolerance_months\": 0,\n \"send_token_email\": true\n}")
req, _ := http.NewRequest("POST", 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.post("https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"expiration_tolerance_months\": 0,\n \"send_token_email\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"expiration_tolerance_months\": 0,\n \"send_token_email\": true\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>",
"expires_at": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Create User Token
Generates an organization access token for the specified user.
POST
/
api
/
v1
/
organizations
/
{org_id}
/
users
/
{user_id}
/
token
Create User Token
curl --request POST \
--url https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expires_at": "2023-11-07T05:31:56Z",
"expiration_tolerance_months": 0,
"send_token_email": true
}
'import requests
url = "https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token"
payload = {
"expires_at": "2023-11-07T05:31:56Z",
"expiration_tolerance_months": 0,
"send_token_email": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expires_at: '2023-11-07T05:31:56Z',
expiration_tolerance_months: 0,
send_token_email: true
})
};
fetch('https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token', 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://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token",
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([
'expires_at' => '2023-11-07T05:31:56Z',
'expiration_tolerance_months' => 0,
'send_token_email' => 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://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token"
payload := strings.NewReader("{\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"expiration_tolerance_months\": 0,\n \"send_token_email\": true\n}")
req, _ := http.NewRequest("POST", 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.post("https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"expiration_tolerance_months\": 0,\n \"send_token_email\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://anaconda.com/api/v1/organizations/{org_id}/users/{user_id}/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"expiration_tolerance_months\": 0,\n \"send_token_email\": true\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>",
"expires_at": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}If
send_token_email is true (the default), the user receives their token via email. The token enables the user to access packages from their organization’s repository channels.Authorizations
Bearer token obtained by authenticating with service account credentials (client_id and client_secret).
See the Getting started page for the full authentication flow.
Path Parameters
Body
application/json
Was this page helpful?