Error On getting the Merchant back

My production had a bunch of errors this morning that I have never seen before. The problem does not seem to be happening anymore. But my users were getting errors this morning. They were getting a nil value back.

Just wondering if this was a known issue that happened this morning and was fixed or if I need to dig into this more. Its the same code I have used for the last three years to call the merchant api.

     merchant = square_api_client.merchants.retrieve_merchant(
        merchant_id: current_account.square_merchant_id
      )
module SquareApiHelper
    def square_api_client
      # Create an instance of the API Client and initialize it with the credentials
      # for the Square account whose assets you want to manage.
      if Rails.env != 'production'
        this_environment = 'sandbox'
      else
        this_environment = 'production'  
      end 

      @api_client ||= Square::Client.new(
        access_token: current_account.square_access_token,
        environment: this_environment
      )
    end
end

EDIT: Found the error in my logs, says Rate Limit.

I did not know there was a Rate Limit on the Merchant api. What is the solution here

{
  "errors": [
    {
      "code": "RATE_LIMITED",
      "detail": "This request was rate limited. Please retry later.",
      "category": "RATE_LIMIT_ERROR"
    }
  ]
}

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Develop for Japan
Develop for Japan
Merchants API

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Were you calling the endpoint more then usual? All our endpoints have rate limits. :slight_smile:

Not today, but its the busy season, so over the weekend they were calling more. Its working fine now. I call devices every time I call merchants, plus I call devices on other pages as well, but did not have an issue with devices

Okay, I’m not familiar with your flow but do you need to be calling merchant a lot? :slight_smile:

From 9/29/2025 until now, I called that end point 502 times

Possibly another concern, is the terminal checkout api. If this has a limit it could cause payment issue on the application. Does the terminal checkout create also have a limit?

Yes, all of our endpoints have rate limits. They do differ based on endpoint because some have higher traffic then others. :slight_smile:

Are terminal rates based off of rates per second, per min, per day. It looks like you don’t disclose the rate limits, but can we figure out how to have an idea of when a limit is getting close or avoid

They’re based on QPS. :slight_smile: