> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.greenlane.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.greenlane.ai/_mcp/server.

# Authorize

POST https://pos.fuel.greenlane.ai/gfp/authorize
Content-Type: application/json

The authorize request is the first step the merchant POS will call when the customer enters a fuel code at the pump or inside the store.

1. All independent requests will have unique transaction ids
    
2. The `authorized_flag` determines whether the authorization was successful. I.e. an HTTP 200 call with `authorized_flag: false` is considered a valid response (where the authorization is declined).
    
3. There are 3 ways to limit the authorization, please review the docs on limits.
The authorize response will include a `voids_at` field which specifies when this authorization will expire. The POS must abide by this field and not allow capture calls after the deadline ends (typically 24 hours).

This endpoint will not return products which are not listed in the `available_fuel` field.

Reference: https://docs.greenlane.ai/greenlane-fuel-platform/authorize

## Authentication

- `Authorization` header (bearer token, required)

## Request

### Body (application/json)

- `merchant_id` (string, required)
- `site_id` (string, required)
- `transaction_id` (string, required)
- `transaction_time_ms` (integer, required)
- `available_fuel` (list of object, required)
  - `product_code` (string, required)
  - `retail_price_per_unit` (double, required)
  - `cost_price_per_unit` (double, required)
  - `unit_of_measure` (string, required)
- `payment_code` (string, required)
- `currency` (string, required)

## Response

### 200

OK

- `merchant_id` (string, required)
- `transaction_id` (string, required)
- `authorized_flag` (boolean, required)
- `voids_at` (integer, required)
- `authorization_code` (string, required)
- `total_amt_limit` (double, required)
- `currency` (string, required)
- `fuel_limits` (list of object, required)
  - `product_code` (string, required)
  - `amount_limit` (integer, required)
  - `volume_limit` (integer, required)

## Examples

### Authorization approved

**Request**

```json
undefined
```

**Response**

```json
{
  "merchant_id": "merchant-123",
  "transaction_id": "123abcd",
  "authorized_flag": true,
  "voids_at": 1787722932000,
  "authorization_code": "QWE4412VF",
  "total_amt_limit": 125.5,
  "currency": "USD",
  "fuel_limits": [
    {
      "product_code": "DIESEL_ULSD",
      "amount_limit": 100,
      "volume_limit": 30
    }
  ]
}
```

**SDK Code**

```python Authorization approved
import requests

url = "https://pos.fuel.greenlane.ai/gfp/authorize"

headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript Authorization approved
const url = 'https://pos.fuel.greenlane.ai/gfp/authorize';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Authorization approved
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://pos.fuel.greenlane.ai/gfp/authorize"

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

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Authorization approved
require 'uri'
require 'net/http'

url = URI("https://pos.fuel.greenlane.ai/gfp/authorize")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Authorization approved
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://pos.fuel.greenlane.ai/gfp/authorize")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Authorization approved
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://pos.fuel.greenlane.ai/gfp/authorize', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Authorization approved
using RestSharp;

var client = new RestClient("https://pos.fuel.greenlane.ai/gfp/authorize");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Authorization approved
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://pos.fuel.greenlane.ai/gfp/authorize")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Authorization declined

**Request**

```json
undefined
```

**Response**

```json
{
  "merchant_id": "LOCATION_ID",
  "transaction_id": "123abcd",
  "authorized_flag": false,
  "voids_at": 1,
  "authorization_code": "string",
  "total_amt_limit": 1.1,
  "currency": "string",
  "fuel_limits": [
    {
      "product_code": "string",
      "amount_limit": 1,
      "volume_limit": 1
    }
  ],
  "denied_reason": "Invalid authorization state"
}
```

**SDK Code**

```python Authorization declined
import requests

url = "https://pos.fuel.greenlane.ai/gfp/authorize"

headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript Authorization declined
const url = 'https://pos.fuel.greenlane.ai/gfp/authorize';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Authorization declined
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://pos.fuel.greenlane.ai/gfp/authorize"

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

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Authorization declined
require 'uri'
require 'net/http'

url = URI("https://pos.fuel.greenlane.ai/gfp/authorize")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Authorization declined
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://pos.fuel.greenlane.ai/gfp/authorize")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Authorization declined
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://pos.fuel.greenlane.ai/gfp/authorize', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Authorization declined
using RestSharp;

var client = new RestClient("https://pos.fuel.greenlane.ai/gfp/authorize");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Authorization declined
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://pos.fuel.greenlane.ai/gfp/authorize")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Authorize_example

**Request**

```json
{
  "merchant_id": "merchant-123",
  "site_id": "123",
  "transaction_id": "123abcd",
  "transaction_time_ms": 1787636532000,
  "available_fuel": [
    {
      "product_code": "DIESEL_ULSD",
      "retail_price_per_unit": 3.999,
      "cost_price_per_unit": 3.65,
      "unit_of_measure": "GALLON"
    }
  ],
  "payment_code": "75123456",
  "currency": "USD"
}
```

**Response**

```json
{
  "merchant_id": "merchant-123",
  "transaction_id": "123abcd",
  "authorized_flag": true,
  "voids_at": 1787722932000,
  "authorization_code": "QWE4412VF",
  "total_amt_limit": 125.5,
  "currency": "USD",
  "fuel_limits": [
    {
      "product_code": "DIESEL_ULSD",
      "amount_limit": 100,
      "volume_limit": 30
    }
  ]
}
```

**SDK Code**

```python Authorize_example
import requests

url = "https://pos.fuel.greenlane.ai/gfp/authorize"

payload = {
    "merchant_id": "merchant-123",
    "site_id": "123",
    "transaction_id": "123abcd",
    "transaction_time_ms": 1787636532000,
    "available_fuel": [
        {
            "product_code": "DIESEL_ULSD",
            "retail_price_per_unit": 3.999,
            "cost_price_per_unit": 3.65,
            "unit_of_measure": "GALLON"
        }
    ],
    "payment_code": "75123456",
    "currency": "USD"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Authorize_example
const url = 'https://pos.fuel.greenlane.ai/gfp/authorize';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"merchant_id":"merchant-123","site_id":"123","transaction_id":"123abcd","transaction_time_ms":1787636532000,"available_fuel":[{"product_code":"DIESEL_ULSD","retail_price_per_unit":3.999,"cost_price_per_unit":3.65,"unit_of_measure":"GALLON"}],"payment_code":"75123456","currency":"USD"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Authorize_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://pos.fuel.greenlane.ai/gfp/authorize"

	payload := strings.NewReader("{\n  \"merchant_id\": \"merchant-123\",\n  \"site_id\": \"123\",\n  \"transaction_id\": \"123abcd\",\n  \"transaction_time_ms\": 1787636532000,\n  \"available_fuel\": [\n    {\n      \"product_code\": \"DIESEL_ULSD\",\n      \"retail_price_per_unit\": 3.999,\n      \"cost_price_per_unit\": 3.65,\n      \"unit_of_measure\": \"GALLON\"\n    }\n  ],\n  \"payment_code\": \"75123456\",\n  \"currency\": \"USD\"\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(res)
	fmt.Println(string(body))

}
```

```ruby Authorize_example
require 'uri'
require 'net/http'

url = URI("https://pos.fuel.greenlane.ai/gfp/authorize")

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  \"merchant_id\": \"merchant-123\",\n  \"site_id\": \"123\",\n  \"transaction_id\": \"123abcd\",\n  \"transaction_time_ms\": 1787636532000,\n  \"available_fuel\": [\n    {\n      \"product_code\": \"DIESEL_ULSD\",\n      \"retail_price_per_unit\": 3.999,\n      \"cost_price_per_unit\": 3.65,\n      \"unit_of_measure\": \"GALLON\"\n    }\n  ],\n  \"payment_code\": \"75123456\",\n  \"currency\": \"USD\"\n}"

response = http.request(request)
puts response.read_body
```

```java Authorize_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://pos.fuel.greenlane.ai/gfp/authorize")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"merchant_id\": \"merchant-123\",\n  \"site_id\": \"123\",\n  \"transaction_id\": \"123abcd\",\n  \"transaction_time_ms\": 1787636532000,\n  \"available_fuel\": [\n    {\n      \"product_code\": \"DIESEL_ULSD\",\n      \"retail_price_per_unit\": 3.999,\n      \"cost_price_per_unit\": 3.65,\n      \"unit_of_measure\": \"GALLON\"\n    }\n  ],\n  \"payment_code\": \"75123456\",\n  \"currency\": \"USD\"\n}")
  .asString();
```

```php Authorize_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://pos.fuel.greenlane.ai/gfp/authorize', [
  'body' => '{
  "merchant_id": "merchant-123",
  "site_id": "123",
  "transaction_id": "123abcd",
  "transaction_time_ms": 1787636532000,
  "available_fuel": [
    {
      "product_code": "DIESEL_ULSD",
      "retail_price_per_unit": 3.999,
      "cost_price_per_unit": 3.65,
      "unit_of_measure": "GALLON"
    }
  ],
  "payment_code": "75123456",
  "currency": "USD"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Authorize_example
using RestSharp;

var client = new RestClient("https://pos.fuel.greenlane.ai/gfp/authorize");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"merchant_id\": \"merchant-123\",\n  \"site_id\": \"123\",\n  \"transaction_id\": \"123abcd\",\n  \"transaction_time_ms\": 1787636532000,\n  \"available_fuel\": [\n    {\n      \"product_code\": \"DIESEL_ULSD\",\n      \"retail_price_per_unit\": 3.999,\n      \"cost_price_per_unit\": 3.65,\n      \"unit_of_measure\": \"GALLON\"\n    }\n  ],\n  \"payment_code\": \"75123456\",\n  \"currency\": \"USD\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Authorize_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "merchant_id": "merchant-123",
  "site_id": "123",
  "transaction_id": "123abcd",
  "transaction_time_ms": 1787636532000,
  "available_fuel": [
    [
      "product_code": "DIESEL_ULSD",
      "retail_price_per_unit": 3.999,
      "cost_price_per_unit": 3.65,
      "unit_of_measure": "GALLON"
    ]
  ],
  "payment_code": "75123456",
  "currency": "USD"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://pos.fuel.greenlane.ai/gfp/authorize")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```