question

jmerola avatar image
jmerola asked David Marginian answered

How to set up connection to production merchant using REST API

Hello,

I am developing an integration between my company's internal resources and Clover specifically for the use case of user provisioning and user management. We are rolling out a decent sized implementation of about 50 merchants, and all user management will be automated based on new hires, employee status changes, etc. I am using the Clover Merchant and Employee API endpoints to accomplish this.


I have been testing with a sandbox environment using an API token that I generated from the Clover web dashboard. Using this token and a MID, I am able to authenticate to my sandbox environment and perform all the actions that I need to. However, I am not able to connect to a production merchant using the same configuration (MID and API token created from that merchant's dashboard).


I'm seeing a lot of info here and at docs.clover.com about OAuth and web apps, but I don't want to integrate with any apps, I just want to be able to create and manage users for each merchant programmatically. What is the recommended process for configuring an API connection to a production merchant?

REST APIMerchantAPI TokenEmployees
10 |2000 characters needed characters left characters exceeded

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

David Marginian avatar image
David Marginian answered

Please see the "Check your Request" section here - https://community.clover.com/articles/23744/resolving-401-unauthorized-responses-when-making-a.html.. Our REST API takes the Clover merchant uuid. You are not passing the correct merchant id.

2 comments
10 |2000 characters needed characters left characters exceeded

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

Thank you. The MID I have was pulled by my co-worker, who has access to the merchant dashboards. I'll get in touch with him to find the correct MID using the documentation you sent and then try my API request again.
0 Likes 0 ·
Thanks again for the help. The alphanumeric Merchant ID is working, I am able to retrieve data from different merchants using the correct MID values. I'm marking this resolved.
0 Likes 0 ·
David Marginian avatar image
David Marginian answered

Can you clarify who this app is for? Are you a developer working for the merchant or are you working for a third party company that is developing services for a variety of merchants?

10 |2000 characters needed characters left characters exceeded

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

jmerola avatar image
jmerola answered David Marginian converted comment to answer

I work for the merchant; we are a medical organization rolling out Clover as our point of sale solution in hospital gift shops and cafes. My integration (we call them “adapters”) will only be used internally to provision and manage accounts in our production Clover environments.

3 comments
10 |2000 characters needed characters left characters exceeded

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

Merchant tokens do work in production, so you would have to provide some details about the error you are seeing (do not provide the token being used, etc.).

That being said with that many merchants, managing merchant tokens may be a problem. The other problem is that merchant tokens are more severely rate limited. For these reasons we generally would recommend an app (private in your case) and OAuth tokens. Even private apps need to go through our approval process and that takes time.

0 Likes 0 ·
jmerola avatar image jmerola David Marginian ♦♦ ·

I don't have a reference on how long it would take to write a private Clover app, get it approved, etc. I don't believe that is the avenue I want to pursue, as I believe I can do everything I need on my side and just submit requests to the REST API to perform the necessary user management functions.


As for a more technical description of my issue-

I'm using Insomnia as my REST client for test purposes. I am sending a GET request to the URL below to receive all user information and expand the roles object for each user. I have removed the MID and API token for security.


> GET /v3/merchants/<MID>/employees?expand=roles HTTP/1.1

> Host: api.clover.com

> User-Agent: insomnia/2021.4.0

> accept: application/json

> authorization: Bearer <API token value>


The response comes back as 401 - Unauthorized.


< HTTP/1.1 401 Unauthorized

< cache-control: no-cache, no-store, must-revalidate

< pragma: no-cache

< expires: Tue, 17 Sep 1991 10:00:00 PST

< content-length: 30

< content-type: application/json; charset=utf-8

< X-Robots-Tag: none



I should note that this exact same HTTP Request works perfectly when the MID and API token are changed to the values for my sandbox Merchant. Example below.


> GET /v3/merchants/<MID>/employees?expand=roles HTTP/1.1

> Host: apisandbox.dev.clover.com

> User-Agent: insomnia/2021.4.0

> accept: application/json

> authorization: Bearer <API Token value>


response:

< HTTP/1.1 200 OK

< cache-control: no-cache, no-store, must-revalidate

< pragma: no-cache

< expires: Tue, 17 Sep 1991 10:00:00 PST

< X-Clover-Allowed-Filter-Fields: modifiedTime, role, role.id, customId, name, nickname, id, deletedTime, deleted_time, email

< content-length: 11454

< content-type: application/json; charset=utf-8

< X-Robots-Tag: none

< X-XSS-Protection: 1; mode=block

< X-Content-Type-Options: nosniff

0 Likes 0 ·

To test the call I would make it via curl or postman and see if you get a response. You will have to provide me the merchant id. Please do that in a moderators only post (Select the Viewable by all users dropdown below the submit button).

0 Likes 0 ·

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