
There are two types of common errors: 401 "Authentication Required" and 402 "Payment Required".
If you keep reading, you can learn about both, as well as these other hot topics:
- Status code 401 - Authentication required
- Status code 402 - Payment required
- When in doubt, contact support
Status code 401 - Authentication required
If you're seeing this error, there's a chance there's an issue with your API key, a mistake in your client-side request, or a mistake in your server-side request. In the recording, Lyle dives deep into each of these, but here are the basics.
How to authenticate API requests
it’s important that you’re familiar with your API keys. Inside your Smarty account, there's an API Keys tab where you can find embedded keys, as well as secret keys. Knowing which keys are used in which environment will help you avoid some errors. If you don't have access to the Smarty account, it may be a good idea to contact the account owner and get access to it.
Understand the difference between client-side requests (in a web browser) and server-side requests. Since browsers automatically send a Referer header, our system treats any request that includes one as a client-side request. In contrast, if the request does NOT have a Referer header, our system treats it as a server-side request.
Common mistakes in client-side requests
For client-side requests, you'll want to use the embedded keys, not the secret keys. Doing so will return a 401 error. Also, don't list the wrong referer/host value with the embedded key. There are a few specific places where your host will be a little different.
- For localhost, just list "localhost" without the port number.
- For calls from the jsfiddle website, the correct host is fiddle.jshell.net
When using a wildcard in a hostname, don't use the * for more than one level of subdomain, or you will get the 401 error.
And lastly, don't forget to URL-encode the request URL. For example, an unencoded # symbol will break the request URL and return an error.
Common mistakes in server-side requests
For server-side requests, you'll want to use the secret keys, not the embedded keys. Don't type the auth-id or auth-token by hand; you might mistype a 1 for a lowercase L or a 0 for a capital O. And of course, don't forget to URL-encode the request URL.
Status code 402 - Payment required
Most of these errors stem from a misunderstanding of how Smarty's products work or what each license provides. There are a few things you can do to avoid these errors.
If you’re a developer working with the Smarty APIs, we recommend that you be able to log in to the Smarty account you’re trying to use. If you’re not the primary account owner, you'll need to obtain those login details from whoever is.
It is beneficial to be familiar with the pages available in your account dashboard, such as Subscriptions and API Keys. Knowing what you have available in the Subscriptions section will help you identify the APIs you are allowed to call and what specific abilities are included. If you’re ever unsure, you can contact the Smarty Support team on any of Smarty's pages via chat, email, or phone.
If you have several accounts with licenses, make sure you're using the correct APIs from the correct accounts. Several of our customers are contractors or independent users who are utilizing several accounts. That may be the first thing you want to check if that’s the case.
If you’re using one of our SDKs, don't assume that the e-license value listed in the GitHub example code is the right one. For example, the default license listed in the GitHub example code is us-rooftop-geocoding-cloud, but you may not have a Rooftop Geocoding license.
When in doubt, contact support
The Smarty support team is here for you. Feel free to contact them anytime you need them!
Regular office hours: Weekdays 7 AM - 5 PM Mountain Time.
Phone: 801-877-5778
Chat: Anywhere on smarty.com
Email: support@smarty.com
Watch the full webinar recording for more information!
Was this helpful?