---
agentTools:
  projectIndex: https://developer-docs.gomotive.com/llms.txt
---

# Update a fuel purchase

**Purpose**: Use this API to update an existing fuel purchase. Note that you must pass important details such as `vehicle_id`, `driver_id`, `jurisdiction`, `fuel_type`, and others in the Body Parameters. Refer to the Body Parameters section for more info.

## OAuth Token

```ruby Ruby (OAuth 2.0)
require 'uri'
require 'net/http'
require 'json'

url = URI('https://api.gomotive.com/v1/fuel_purchases/1')

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

request = Net::HTTP::Put.new(url)
request['Authorization'] = "Bearer <OAUTH_TOKEN>"
request['Content-Type'] = 'application/json'
params = {
  :vehicle_id   => 1,
  :driver_id    => 2,
  :purchased_at => '2019-04-23',
  :jurisdiction => 'AL',
  :fuel_type    => 'diesel',
  :fuel         => 13,
  :fuel_unit    => 'gal'
}
request.body = params.to_json

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

## Response Parameters

### id

* **Type**: Integer
* **Description**: The unique identifier for the fuel purchase.

### offline\_id

* **Type**: String
* **Description**: The offline identifier associated with the fuel purchase.

### purchased\_at

* **Type**: String (DateTime)
* **Description**: The date and time when the fuel was purchased.

### jurisdiction

* **Type**: String
* **Description**: The jurisdiction where the fuel purchase occurred (e.g., state or region code).

### fuel\_type

* **Type**: String
* **Description**: The type of fuel purchased (e.g., diesel).

### ref\_no

* **Type**: String
* **Description**: The reference number for the fuel purchase.

### vendor

* **Type**: String
* **Description**: The vendor from whom the fuel was purchased.

### total\_cost

* **Type**: Integer
* **Description**: The total cost of the fuel purchase.

### currency

* **Type**: String
* **Description**: The currency used for the purchase (e.g., USD).

### fuel

* **Type**: Integer
* **Description**: The amount of fuel purchased.

### fuel\_unit

* **Type**: String
* **Description**: The unit of measurement for the fuel (e.g., gal).

### odometer

* **Type**: Integer or Null
* **Description**: The odometer reading at the time of fuel purchase.

### odometer\_unit

* **Type**: String
* **Description**: The unit of measurement for the odometer (e.g., mi).

### receipt\_upload\_url

* **Type**: String or Null
* **Description**: The URL where the receipt can be downloaded.

### receipt\_filename

* **Type**: String or Null
* **Description**: The filename of the receipt.

### uploader

* **Type**: Object
* **Description**: Information about the person who uploaded the fuel purchase.
  * **id**: Integer — The unique identifier of the uploader.
  * **first\_name**: String — The first name of the uploader.
  * **last\_name**: String — The last name of the uploader.
  * **email**: String — The email address of the uploader.
  * **role**: String — The role of the uploader.
  * **deactivated\_at**: String or Null — The date and time when the uploader was deactivated.

### vehicle

* **Type**: Object
* **Description**: Information about the vehicle associated with the fuel purchase.
  * **id**: Integer — The unique identifier of the vehicle.
  * **number**: String — The vehicle number.
  * **year**: String — The year of the vehicle.
  * **make**: String — The make of the vehicle.
  * **model**: String — The model of the vehicle.
  * **vin**: String — The Vehicle Identification Number.
  * **metric\_units**: Boolean — Indicates if the vehicle uses metric units.

### driver

* **Type**: Object
* **Description**: Information about the driver associated with the fuel purchase.
  * **id**: Integer — The unique identifier of the driver.
  * **first\_name**: String — The first name of the driver.
  * **last\_name**: String — The last name of the driver.
  * **username**: String — The username of the driver.
  * **email**: String — The email address of the driver.
  * **driver\_company\_id**: String or Null — The ID of the driver's company.
  * **status**: String — The status of the driver (e.g., active).
  * **role**: String — The role of the driver.

***

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Motive",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.gomotive.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/fuel_purchases/{id}": {
      "put": {
        "summary": "Update a fuel purchase",
        "description": "",
        "operationId": "update-an-existing-fuel-purchase",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Specify the ID of the fuel purchase transaction which needs to be updated.",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "required": true
          },
          {
            "name": "source",
            "in": "query",
            "description": "This is the payment source of the current fuel purchase. Allowed values are as follows: <b>efs-integration</b>, <b>COMDATA_INTEGRATION</b>, <b>WEX_INTEGRATION</b>, <b>Manual</b>, <b>Motive Card</b>, <b>GIR (GIR W150 Fuel Management System)</b>.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "vehicle_id",
                  "driver_id"
                ],
                "properties": {
                  "vehicle_id": {
                    "type": "string",
                    "description": "Specify the ID of the vehicle for which you are updating the fuel purchase."
                  },
                  "driver_id": {
                    "type": "string",
                    "description": "Specify the ID of the driver for whom you are updating this fuel purchase."
                  },
                  "purchased_at": {
                    "type": "string",
                    "description": "Time of fuel purchase",
                    "format": "date"
                  },
                  "jurisdiction": {
                    "type": "string",
                    "description": "Jurisdiction in which fuel was purchased"
                  },
                  "fuel_type": {
                    "type": "string",
                    "description": "Type of fuel. Valid values are ['diesel', 'gasoline', 'propane', 'lng', 'cng', 'ethanol', 'methanol', 'e85', 'm85', 'a55', 'biodiesel', 'other']"
                  },
                  "total_cost": {
                    "type": "string",
                    "description": "Specify the total cost of the fuel purchase."
                  },
                  "currency": {
                    "type": "string",
                    "description": "Specify the currency in which the fuel was purchased. Allowed values are USD or CAD."
                  },
                  "fuel": {
                    "type": "string",
                    "description": "Specify the total amount of the fuel purchased."
                  },
                  "fuel_unit": {
                    "type": "string",
                    "description": "Specify the units of the fuel. Allowed values are gal for Gallons, or ltr for Litres."
                  },
                  "ref_no": {
                    "type": "string",
                    "description": "Specify the reference number of the fuel purchase."
                  },
                  "vendor": {
                    "type": "string",
                    "description": "Enter the name of the fuel vendor."
                  },
                  "odometer": {
                    "type": "integer",
                    "description": "Odometer reading at time of fuel purchase",
                    "format": "int32"
                  },
                  "odometer_unit": {
                    "type": "string",
                    "description": "Specify the units of the odometer at the time of the fuel purchase. Allowed values are: KM for Kilometres, or MI for Miles."
                  },
                  "receipt": {
                    "type": "array",
                    "description": "Specify the URL of the location where the receipt is uploaded.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "location": {
                    "type": "string",
                    "description": "Specify the location of the fuel purchase."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Update a fuel purchase": {
                    "value": "  {\n  \"fuel_purchase\": {\n    \"id\": 699,\n    \"offline_id\": \"c4ef3132-3a75-43c7-acc7-9b4aa8c866c9\",\n    \"purchased_at\": \"2018-06-13T18:43:00Z\",\n    \"jurisdiction\": \"AL\",\n    \"fuel_type\": \"diesel\",\n    \"ref_no\": null,\n    \"vendor\": null,\n    \"total_cost\": 150,\n    \"currency\": \"USD\",\n    \"fuel\": 12,\n    \"fuel_unit\": \"gal\",\n    \"odometer\": null,\n    \"odometer_unit\": \"mi\",\n    \"receipt_upload_url\": null,\n    \"receipt_filename\": null,\n    \"location\": \"location\",\n    \"uploader\": {\n      \"id\": 8451,\n      \"first_name\": \"George\",\n      \"last_name\": \"Henry\",\n      \"email\": \"george.henry+bn@keeptruckin.com\",\n      \"role\": \"dispatcher\",\n      \"deactivated_at\": null\n    },\n    \"vehicle\": {\n      \"id\": 4116,\n      \"number\": \"Jason's Vehicle\",\n      \"year\": \"\",\n      \"make\": \"\",\n      \"model\": \"\",\n      \"vin\": \"\",\n      \"metric_units\": false\n    },\n    \"driver\": {\n      \"id\": 2463,\n      \"first_name\": \"Paul\",\n      \"last_name\": \"Walker\",\n      \"username\": \"paul\",\n      \"email\": \"demo@keeptruckin.com\",\n      \"driver_company_id\": null,\n      \"status\": \"active\",\n      \"role\": \"driver\"\n    }\n  }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "fuel_purchase": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer",
                          "example": 699,
                          "default": 0
                        },
                        "offline_id": {
                          "type": "string",
                          "example": "c4ef3132-3a75-43c7-acc7-9b4aa8c866c9"
                        },
                        "purchased_at": {
                          "type": "string",
                          "example": "2018-06-13T18:43:00Z"
                        },
                        "jurisdiction": {
                          "type": "string",
                          "example": "AL"
                        },
                        "fuel_type": {
                          "type": "string",
                          "example": "diesel"
                        },
                        "ref_no": {},
                        "vendor": {},
                        "total_cost": {
                          "type": "integer",
                          "example": 150,
                          "default": 0
                        },
                        "currency": {
                          "type": "string",
                          "example": "USD"
                        },
                        "fuel": {
                          "type": "integer",
                          "example": 12,
                          "default": 0
                        },
                        "fuel_unit": {
                          "type": "string",
                          "example": "gal"
                        },
                        "odometer": {},
                        "odometer_unit": {
                          "type": "string",
                          "example": "mi"
                        },
                        "receipt_upload_url": {},
                        "receipt_filename": {},
                        "location": {
                          "type": "string",
                          "example": "location"
                        },
                        "uploader": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "integer",
                              "example": 8451,
                              "default": 0
                            },
                            "first_name": {
                              "type": "string",
                              "example": "George"
                            },
                            "last_name": {
                              "type": "string",
                              "example": "Henry"
                            },
                            "email": {
                              "type": "string",
                              "example": "george.henry+bn@keeptruckin.com"
                            },
                            "role": {
                              "type": "string",
                              "example": "dispatcher"
                            },
                            "deactivated_at": {}
                          }
                        },
                        "vehicle": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "integer",
                              "example": 4116,
                              "default": 0
                            },
                            "number": {
                              "type": "string",
                              "example": "Jason's Vehicle"
                            },
                            "year": {
                              "type": "string",
                              "example": ""
                            },
                            "make": {
                              "type": "string",
                              "example": ""
                            },
                            "model": {
                              "type": "string",
                              "example": ""
                            },
                            "vin": {
                              "type": "string",
                              "example": ""
                            },
                            "metric_units": {
                              "type": "boolean",
                              "example": false,
                              "default": true
                            }
                          }
                        },
                        "driver": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "integer",
                              "example": 2463,
                              "default": 0
                            },
                            "first_name": {
                              "type": "string",
                              "example": "Paul"
                            },
                            "last_name": {
                              "type": "string",
                              "example": "Walker"
                            },
                            "username": {
                              "type": "string",
                              "example": "paul"
                            },
                            "email": {
                              "type": "string",
                              "example": "demo@keeptruckin.com"
                            },
                            "driver_company_id": {},
                            "status": {
                              "type": "string",
                              "example": "active"
                            },
                            "role": {
                              "type": "string",
                              "example": "driver"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Could not be updated": {
                    "value": "{\n  \"error_message\": \"fuel purchase could not be updated\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error_message": {
                      "type": "string",
                      "example": "fuel purchase could not be updated"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "404",
            "content": {
              "application/json": {
                "examples": {
                  "Not found": {
                    "value": "{\n  \"error_message\": \"fuel_purchase not found\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error_message": {
                      "type": "string",
                      "example": "fuel_purchase not found"
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "66acf64a829e88001980fbf2:66ccd99bc893b3000f3fd2f3"
}
```