Optimization API

31 views
Skip to first unread message

Simon Laridan

unread,
Nov 15, 2025, 3:25:50 AMNov 15
to Google Apps Script Community
Hello, 

I am trying to call the optimization API using Apps Script. 
However, getting this error: 
 ReferenceError: Optimization is not defined
Code.gs:73

From my understanding, I need to add Optimization AI as a service, however, when I look at the list of services, Optimization AI is not in the list. Anybody would know why? Is it because It is available only in a certain country? 

Thank you for your help! 

DimuDesigns

unread,
Nov 15, 2025, 10:11:16 AMNov 15
to Google Apps Script Community
I assume you are referencing the Linear Optimization Service.

The Linear Optimization service is a Built-in utility service (note that Advanced services are distinct from Built-in services; Advanced services need to be enabled, Built-in services do not).

So there is no need to enable the Linear Optimization service.

So there is probably something wrong with your code.

Share the code and maybe someone here can help you to troubleshoot the issue.


DimuDesigns

unread,
Nov 15, 2025, 10:24:00 AMNov 15
to Google Apps Script Community
Re-read you question and saw the reference to the 'runTransportationOptimization' function.

Ignore my previous answer as it is not directly related to your question.

I suspect you are trying to use the Route Optimization API from Google Maps.

Google Apps script has limited native support for Google Maps APIs. There is a built-in Google Maps service, but the Route Optimization API is not included.

You'll probably have to build a custom integration using UrlFetchApp.fetch to call the API directly.  





DimuDesigns

unread,
Nov 15, 2025, 10:28:31 AMNov 15
to Google Apps Script Community
Something to note, the Routes API is relative new, becoming generally available in 2024.

See https://developers.google.com/maps/documentation/route-optimization/release-notes

It may be years before we see native integration with Apps Script - if ever.



Reply all
Reply to author
Forward
0 new messages