{"_id":"54f8de4f4339bb1900c8c004","editedParams":true,"__v":11,"editedParams2":true,"githubsync":"","version":{"_id":"54f8de4e4339bb1900c8bffb","project":"54c0e51215af820d001a38a6","forked_from":"54f8de14c6cabe23005c02a2","__v":33,"createdAt":"2015-03-05T22:53:02.044Z","releaseDate":"2015-03-05T22:53:02.044Z","categories":["54f8de4e4339bb1900c8bffc","54f8de4e4339bb1900c8bffd","54f8de4e4339bb1900c8bffe","54f8de4e4339bb1900c8bfff","54f8de4e4339bb1900c8c000","54ff6057563d7419002d666e","55007b6ecfeeea17004717dc","5501d779f2ef1e0d003116eb","55116ef89f7c7619005f853b","554bb366f245703100ddd39f","554d226b374fec0d007e64db","555e09f18ab3180d001ac605","555e0b2b4f5e5a0d00836d77","561d1f8b92a0cc350018b24f","562a956c96b5f40d0026eb60","5654c3378a26202b00c17cb8","5697a94b0b09a41900b24546","5739d89e37b52e3200a3a3cc","57ac94252c0b220e00a94570","57ac97a1ad44fc0e003be066","57ac9a3a8f312d0e00e96c75","57ac9c187ae5c60e004ba3a3","58178bee62e4500f009404f6","581a39711a63870f008b621d","581a3b4f0c65b20f00247fcb","5926e0606c729e0f00595f95","5954033ea5bbca002d27ae91","596ce53e0aeafe00157eb1ba","596ce87a8b79f4001a8f6139","598cad2e96193400190d879a","598cbcd3dc20c6000fdfb9c3","598cbd8496193400190d8955","59fcc7c9591add0026c91457","5a020b7856ea82001c8c9342","5a09bc64a91882001c56c2ed","5a71fa2de9aa84007a8bccdb","5b3a768a8a21dd0003ca080d"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"category":{"_id":"54f8de4e4339bb1900c8bffe","pages":["54f8de4f4339bb1900c8c001","54f8de4f4339bb1900c8c002","54f8de4f4339bb1900c8c003","54f8de4f4339bb1900c8c004","54f8de4f4339bb1900c8c005","54fdc01521538c21006c49d7"],"project":"54c0e51215af820d001a38a6","version":"54f8de4e4339bb1900c8bffb","__v":2,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-02-02T21:23:51.660Z","from_sync":false,"order":6,"slug":"meter-entries","title":"Meter Entries"},"parentDoc":null,"user":"54cba76f6d1eee0d00c33dee","project":"54c0e51215af820d001a38a6","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-02-03T19:35:13.317Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"method":"patch","results":{"codes":[{"language":"json","code":"","name":"","status":204},{"name":"","status":422,"language":"json","code":"{\n    \"errors\": {\n        \"date\": [\n            \"can't be blank\"\n        ]\n    }\n}"}]},"settings":"","examples":{"codes":[]},"auth":"required","params":[{"_id":"54d122f1875f240d002cb7c6","ref":"","in":"path","required":false,"desc":"","default":"","type":"int","name":"id"},{"_id":"54d1234e7493b40d00400280","ref":"","in":"body","required":false,"desc":"","default":"","type":"yyyy-mm-dd","name":"date"},{"_id":"54d1234e7493b40d0040027f","ref":"","in":"body","required":false,"desc":"Leave blank for primary meter, set to `secondary` if saving an entry for a vehicle's secondary meter.","default":"","type":"string","name":"meter_type"},{"_id":"54d1234e7493b40d0040027c","ref":"","in":"body","required":false,"desc":"The `value` is the actual number on the meter entry that increments over time. An example `value` would be 100,000. But 100,000 what? Miles, Kilometers, Hours? This is determined by the `meter_unit` on the associated vehicle. You can't create one Meter Entry in Miles and then the very next one for the same vehicle in Kilometers. The `meter_unit` on the vehicle is the one source of truth for the measurement type for all Meter Entries on a given vehicle.","default":"","type":"int","name":"value"},{"_id":"54d1234e7493b40d0040027b","ref":"","in":"body","required":false,"desc":"","default":"","type":"boolean","name":"void"}],"url":"/meter_entries/:id"},"isReference":true,"order":3,"body":"Fleetio requires that odometer updates never go backwards since odometers are incremental in real life. This allows Fleetio to make reports that accurately reflect reality since we are not dealing with impossible math situations. As such, this introduces a few considerations when updating meter entries via the API. Let's say that we have a vehicle with the following odometer readings:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/5bda3be-image-1.jpg\",\n        \"image-1.jpg\",\n        2880,\n        1432,\n        \"#ecedee\"\n      ]\n    }\n  ]\n}\n[/block]\nIf we realized that the reading on February 1st should be 181,500 miles rather than 181,000 miles, we can update this via the API without voiding it.\n\n```\ncurl https://secure.fleetio.com/api/v1/meter_entries/16779437 --request PATCH --header 'Authorization: Token token=\"12345abcxyzhasggwllsirusy12345\"' --header \"Account-Token: 12345hbl78b\" --header \"Content-Type: application/json\" --data '{\"vehicle_id\": \"28865\", \"date\": \"2018-02-01\", \"value\": \"181500\"}'\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/f1a4638-image-2.jpg\",\n        \"image-2.jpg\",\n        2880,\n        1432,\n        \"#ecedee\"\n      ]\n    }\n  ]\n}\n[/block]\nThe only time we're going to run into an issue is if we start to get things out of order. So let's say that we wanted to set the reading in February 1st to be 182,500 miles, which is greater than the reading on March 1st, which is 182,000 miles. Now we have a problem because its impossible for the odometer to go backwards like that. Fleetio can't do its reporting and math on impossible values because the math simply doesn't work.\n\n```\ncurl https://secure.fleetio.com/api/v1/meter_entries/16779437 --request PATCH --header 'Authorization: Token token=\"12345abcxyzhasggwllsirusy12345\"' --header \"Account-Token: 12345hbl78b\" --header \"Content-Type: application/json\" --data '{\"vehicle_id\": \"28865\", \"date\": \"2018-02-01\", \"value\": \"182500\"}'\n=> {\"errors\":{\"value\":[\"must be between 180,000 and 182,000 or marked as void\"]}}\n```\n\nThe quick and dirty way is to just set the February 1st meter entry as void and skip the reporting.\n\n```\ncurl https://secure.fleetio.com/api/v1/meter_entries/16779437 --request PATCH --header 'Authorization: Token token=\"12345abcxyzhasggwllsirusy12345\"' --header \"Account-Token: 12345hbl78b\" --header \"Content-Type: application/json\" --data '{\"vehicle_id\": \"28865\", \"date\": \"2018-02-01\", \"value\": \"182500\", \"void\": \"true\"}'\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/e1b1fb4-image-3.jpg\",\n        \"image-3.jpg\",\n        2880,\n        1390,\n        \"#eff0ef\"\n      ]\n    }\n  ]\n}\n[/block]\nBut if you want the reporting to remain intact, there is a workaround.\n\nThe solution is to edit the odometer readings in an order so that the odometer is never out of incremental order. For example, I would edit the reading on March 1st to be 183,000 miles first, and then I could edit the reading on February 1st to be 182,500 miles. Since we maintain the proper logic without ever getting into an impossible math situation, there is no need to void the meter entries, and you keep your reporting intact.\n\n```\ncurl https://secure.fleetio.com/api/v1/meter_entries/16779438 --request PATCH --header 'Authorization: Token token=\"12345abcxyzhasggwllsirusy12345\"' --header \"Account-Token: 12345hbl78b\" --header \"Content-Type: application/json\" --data '{\"vehicle_id\": \"28865\", \"date\": \"2018-03-01\", \"value\": \"183000\"}'\n\ncurl https://secure.fleetio.com/api/v1/meter_entries/16779437 --request PATCH --header 'Authorization: Token token=\"12345abcxyzhasggwllsirusy12345\"' --header \"Account-Token: 12345hbl78b\"  --header \"Content-Type: application/json\" --data '{\"vehicle_id\": \"28865\", \"date\": \"2018-02-01\", \"value\": \"182500\"}'\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/de3e21a-image-4.jpg\",\n        \"image-4.jpg\",\n        2880,\n        1394,\n        \"#ebeded\"\n      ]\n    }\n  ]\n}\n[/block]\nNow you know about editing odometers via the API. Happy metering!","excerpt":"Update a single meter entry","slug":"vehiclesvehicle_idmeter_entriesid-1","type":"endpoint","title":"/meter_entries/:id"}

patch/meter_entries/:id

Update a single meter entry

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

id:
integer

Body Params

date:
yyyy-mm-dd
meter_type:
string
Leave blank for primary meter, set to `secondary` if saving an entry for a vehicle's secondary meter.
value:
integer
The `value` is the actual number on the meter entry that increments over time. An example `value` would be 100,000. But 100,000 what? Miles, Kilometers, Hours? This is determined by the `meter_unit` on the associated vehicle. You can't create one Meter Entry in Miles and then the very next one for the same vehicle in Kilometers. The `meter_unit` on the vehicle is the one source of truth for the measurement type for all Meter Entries on a given vehicle.
void:
boolean

Documentation

Fleetio requires that odometer updates never go backwards since odometers are incremental in real life. This allows Fleetio to make reports that accurately reflect reality since we are not dealing with impossible math situations. As such, this introduces a few considerations when updating meter entries via the API. Let's say that we have a vehicle with the following odometer readings: [block:image] { "images": [ { "image": [ "https://files.readme.io/5bda3be-image-1.jpg", "image-1.jpg", 2880, 1432, "#ecedee" ] } ] } [/block] If we realized that the reading on February 1st should be 181,500 miles rather than 181,000 miles, we can update this via the API without voiding it. ``` curl https://secure.fleetio.com/api/v1/meter_entries/16779437 --request PATCH --header 'Authorization: Token token="12345abcxyzhasggwllsirusy12345"' --header "Account-Token: 12345hbl78b" --header "Content-Type: application/json" --data '{"vehicle_id": "28865", "date": "2018-02-01", "value": "181500"}' ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/f1a4638-image-2.jpg", "image-2.jpg", 2880, 1432, "#ecedee" ] } ] } [/block] The only time we're going to run into an issue is if we start to get things out of order. So let's say that we wanted to set the reading in February 1st to be 182,500 miles, which is greater than the reading on March 1st, which is 182,000 miles. Now we have a problem because its impossible for the odometer to go backwards like that. Fleetio can't do its reporting and math on impossible values because the math simply doesn't work. ``` curl https://secure.fleetio.com/api/v1/meter_entries/16779437 --request PATCH --header 'Authorization: Token token="12345abcxyzhasggwllsirusy12345"' --header "Account-Token: 12345hbl78b" --header "Content-Type: application/json" --data '{"vehicle_id": "28865", "date": "2018-02-01", "value": "182500"}' => {"errors":{"value":["must be between 180,000 and 182,000 or marked as void"]}} ``` The quick and dirty way is to just set the February 1st meter entry as void and skip the reporting. ``` curl https://secure.fleetio.com/api/v1/meter_entries/16779437 --request PATCH --header 'Authorization: Token token="12345abcxyzhasggwllsirusy12345"' --header "Account-Token: 12345hbl78b" --header "Content-Type: application/json" --data '{"vehicle_id": "28865", "date": "2018-02-01", "value": "182500", "void": "true"}' ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/e1b1fb4-image-3.jpg", "image-3.jpg", 2880, 1390, "#eff0ef" ] } ] } [/block] But if you want the reporting to remain intact, there is a workaround. The solution is to edit the odometer readings in an order so that the odometer is never out of incremental order. For example, I would edit the reading on March 1st to be 183,000 miles first, and then I could edit the reading on February 1st to be 182,500 miles. Since we maintain the proper logic without ever getting into an impossible math situation, there is no need to void the meter entries, and you keep your reporting intact. ``` curl https://secure.fleetio.com/api/v1/meter_entries/16779438 --request PATCH --header 'Authorization: Token token="12345abcxyzhasggwllsirusy12345"' --header "Account-Token: 12345hbl78b" --header "Content-Type: application/json" --data '{"vehicle_id": "28865", "date": "2018-03-01", "value": "183000"}' curl https://secure.fleetio.com/api/v1/meter_entries/16779437 --request PATCH --header 'Authorization: Token token="12345abcxyzhasggwllsirusy12345"' --header "Account-Token: 12345hbl78b" --header "Content-Type: application/json" --data '{"vehicle_id": "28865", "date": "2018-02-01", "value": "182500"}' ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/de3e21a-image-4.jpg", "image-4.jpg", 2880, 1394, "#ebeded" ] } ] } [/block] Now you know about editing odometers via the API. Happy metering!

User Information

Try It Out

patch
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}