Skip to main content
POST
/
oauth
/
token
Create a token
curl --request POST \
  --url https://api.nomos.energy/oauth/token \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "grant_type": "authorization_code",
  "code": "4/P7q7W91a-oMsCeLvIaQm6bTrgtp7",
  "refresh_token": "1B4a2e77838347a7E420ce178F2E7c6912E169246c",
  "client_id": "client_12345",
  "scope": "<string>",
  "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
}
'
import requests

url = "https://api.nomos.energy/oauth/token"

payload = {
"grant_type": "authorization_code",
"code": "4/P7q7W91a-oMsCeLvIaQm6bTrgtp7",
"refresh_token": "1B4a2e77838347a7E420ce178F2E7c6912E169246c",
"client_id": "client_12345",
"scope": "<string>",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
grant_type: 'authorization_code',
code: '4/P7q7W91a-oMsCeLvIaQm6bTrgtp7',
refresh_token: '1B4a2e77838347a7E420ce178F2E7c6912E169246c',
client_id: 'client_12345',
scope: '<string>',
code_verifier: 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'
})
};

fetch('https://api.nomos.energy/oauth/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://api.nomos.energy/oauth/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([
'grant_type' => 'authorization_code',
'code' => '4/P7q7W91a-oMsCeLvIaQm6bTrgtp7',
'refresh_token' => '1B4a2e77838347a7E420ce178F2E7c6912E169246c',
'client_id' => 'client_12345',
'scope' => '<string>',
'code_verifier' => 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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://api.nomos.energy/oauth/token"

payload := strings.NewReader("{\n \"grant_type\": \"authorization_code\",\n \"code\": \"4/P7q7W91a-oMsCeLvIaQm6bTrgtp7\",\n \"refresh_token\": \"1B4a2e77838347a7E420ce178F2E7c6912E169246c\",\n \"client_id\": \"client_12345\",\n \"scope\": \"<string>\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n}")

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

req.Header.Add("Authorization", "Basic <encoded-value>")
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://api.nomos.energy/oauth/token")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"grant_type\": \"authorization_code\",\n \"code\": \"4/P7q7W91a-oMsCeLvIaQm6bTrgtp7\",\n \"refresh_token\": \"1B4a2e77838347a7E420ce178F2E7c6912E169246c\",\n \"client_id\": \"client_12345\",\n \"scope\": \"<string>\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.nomos.energy/oauth/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"grant_type\": \"authorization_code\",\n \"code\": \"4/P7q7W91a-oMsCeLvIaQm6bTrgtp7\",\n \"refresh_token\": \"1B4a2e77838347a7E420ce178F2E7c6912E169246c\",\n \"client_id\": \"client_12345\",\n \"scope\": \"<string>\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n}"

response = http.request(request)
puts response.read_body
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlcyI6WyJhZG1pbiJdLCJwYJ0bmVyIjoi...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "21cc84a3ad98736f4e5eddc88a1f4b58a29ae96206027c9b59d874cb2a7f7e02",
  "scope": "read:* write:*"
}
{
"code": "BAD_REQUEST",
"message": "invalid_type in 'end': Required",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/BAD_REQUEST"
}
{
"code": "UNAUTHORIZED",
"message": "Invalid or malformed token",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/UNAUTHORIZED"
}
{
"code": "PAYMENT_REQUIRED",
"message": "Payment required",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/PAYMENT_REQUIRED"
}
{
"code": "FORBIDDEN",
"message": "You are not allowed to access this resource",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/FORBIDDEN"
}
{
"code": "NOT_FOUND",
"message": "Resource not found",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/NOT_FOUND"
}
{
"code": "METHOD_NOT_ALLOWED",
"message": "Method not allowed",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/METHOD_NOT_ALLOWED"
}
{
"code": "CONFLICT",
"message": "Resource already exists",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/CONFLICT"
}
{
"code": "UNPROCESSABLE_ENTITY",
"message": "invalid_enum_value in 'status': Invalid enum value. Expected 'pending' | 'active' | 'ended'",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/UNPROCESSABLE_ENTITY"
}
{
"code": "TOO_MANY_REQUESTS",
"message": "Wait 30 seconds before retrying.",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/TOO_MANY_REQUESTS"
}
{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal Server Error",
"requestId": "37a04f8f-e791-491c-81e1-86cd304649bb",
"docs": "https://docs.nomos.energy/api-references/errors/INTERNAL_SERVER_ERROR"
}

Authorizations

Authorization
string
header
required

Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.

Body

application/json

The token request

grant_type
enum<string>
required

The OAuth 2.0 grant type being used for the token request

Available options:
authorization_code,
refresh_token,
client_credentials
Example:

"authorization_code"

code
string

The authorization code received from the authorization server (required for authorization_code grant type)

Example:

"4/P7q7W91a-oMsCeLvIaQm6bTrgtp7"

refresh_token
string

The refresh token used to obtain a new access token (required for refresh_token grant type)

Example:

"1B4a2e77838347a7E420ce178F2E7c6912E169246c"

client_id
string

The client identifier issued to the client during registration (required for public clients, when not authenticating via Basic Auth)

Example:

"client_12345"

scope
string
code_verifier
string

PKCE code verifier used to verify the authorization request (required when PKCE was used in authorization request)

Example:

"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"

Response

Retrieve the quote details

access_token
string
required

The access token to access the API endpoints

Example:

"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlcyI6WyJhZG1pbiJdLCJwYJ0bmVyIjoi..."

token_type
enum<string>
required

The type of token issued, always 'Bearer'

Available options:
Bearer
Example:

"Bearer"

expires_in
number
required

The lifetime of the access token in seconds (60 minutes)

Example:

3600

refresh_token
string
required

The refresh token to create a new access_token

Example:

"21cc84a3ad98736f4e5eddc88a1f4b58a29ae96206027c9b59d874cb2a7f7e02"

scope
string
required

Space-delimited list of scopes granted on this token (RFC 6749).

Example:

"read:* write:*"