question

vin avatar image
vin asked vin answered

Use API token to make REST calls to my clover account

I would like to use Clover's REST API to programmatically access data in my Clover account. For example, I want to download sales data nightly to my server to update my database automatically.

I created an API token from the setting on my Clover account. However, using it for authentication returns a 401. I scoured the Clover documentation for a use case such as mine but didn't find anything. I don't know if what I want to do is possible. Also, I don't understand how the API token I generated is supposed to be used.

In summary, my first question is: Can I use the REST API to access the data in my own Clover account without being a developer and developing an app?

My second question is more for my edification: How is the API token generated in the Clover account dashboard used?

Thank you for your assistance.

REST APIAPI Token
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

parquet76 avatar image
parquet76 answered

Yes, you can use it. Do you have experience using APIs and know how to make a request? You need to pass the token using the authorization header and you also need to make sure you are using the correct merchant ID (13 char alpha numeric).

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

vin avatar image
vin answered vin edited

Thanks for the quick response.

I have much experience with REST. I am using the correct MID and the correct API Token, which is passed in bearer authorization. But the result is a 401. I attached a screenshot of Postman. When the MID & token are for the test merchant in my sandbox it works (using the sandbox url, of course).

I tried it with a couple of API tokens and several endpoints. All return 401.

Even though this hasn't resolve my issue, it is good to know that it can be done. Of course other suggestions are most welcome.

Thanks a lot.


screenshot-2024-08-30-at-125406pm.png



10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

parquet76 avatar image
parquet76 answered

Clover has a documentation page on 401s - https://docs.clover.com/dev/docs/401-unauthorized. You can disregard the info about apps, you probably are using the wrong token (trying to use sandbox token in prod), or your merchant ID is incorrect. The screenshot you attached isn't helpful.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

parquet76 avatar image
parquet76 answered

If you still need help with this issue, provide us with a screenshot of the clover dashboard containing the permissions on the token you created and the details of the request you are making (you can get this in.postman by selecting the code/curl link). Make sure you redact the token and any other privileged info.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

vin avatar image
vin answered parquet76 edited

Yes, I am still having problems. Below are request to 2 endpoints that return 401.

$ curl --location 'https://api.clover.com/v3/merchants/52********89' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer 64a******************************64c'
{"message":"401 Unauthorized"}%
$ curl --location 'https://api.clover.com/v3/merchants/52********89/orders' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer 64a*****************************764c'
{"message":"401 Unauthorized"}%

Attached are screenshot showing my MID and token.

Thanks for your help.

screenshot-2024-09-03-at-83301am.png


token.jpg


3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

parquet76 avatar image parquet76 commented ·

The merchant ID is 13 char alpha-numeric, it will contain letters, are you sure you're using the correct merchant ID?

0 Likes 0 ·
vin avatar image vin parquet76 commented ·

The MID for my production instance is 12 digits -- see the screenshot of my dashboard I shared. The 12-digit MID is also on my invoices. So I am fairly certain that my product MID is 12 digits long. However, the MID for my test merchants is 13 alphanumeric chars.

I have found documentation regarding using the API token from a test merchant account in the sandbox. And this is working for me. I have scoured the API documentation for how to use the API token in the production environment. Every page I have seen discusses using an access token generated by OAuth to read production data. Can you share a link to documentation on how to use the API token that I created in my dashboard (ie, the one in the screenshot I shared) in production?

Thank you for your help.

0 Likes 0 ·
parquet76 avatar image parquet76 vin commented ·

The MID is NOT the merchant ID you should be using for API calls. The id you should be using is ALWAYS 13 alpha-numeric characters. You can generally find it in the url bar if you are browsing the merchant dashboard (after the merchant section in the path). If you use the correct merchant ID your API call will work. Oauth is for apps, you don't need an app.

0 Likes 0 ·
vin avatar image
vin answered

Yep: I was using my 12-digit merchant ID not my 13-char merchant ID. Thanks for walking me through this.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community