<p>The error was my client connected to the wrong endpoint. This feature was undocumented at the time, but is now <a href="https://github.com/bitpay/ruby-client#testnet-usage" rel="nofollow">clearly documented</a>. Kudos to Bitpay! </p>

CC BY-SA 3.0
2014-10-19T20:07:53.930Z
This isn't quite fair. First, Bitpay support was available to you for help. Second, the old API did still work if you used the right endpoint, and that was not something hardcoded into the library. Third, both the version 1 and 2 libraries are available on RubyGems. https://rubygems.org/gems/bitpay-client/
philosodad
CC BY-SA 3.0
2014-10-20T15:57:49.740Z
You're right, that was unfair. I beg your apologies and  made an updated answer. Thanks for providing a great service!
Martin Josefsson
CC BY-SA 3.0
2014-09-18T22:15:58.117Z
2014-10-20T15:56:43.587Z
2014-10-20T15:56:43.587Z
Martin Josefsson
<p>I'm creating a web app that uses Bitpay for payments. I'm writing it in ruby (but that shouldn't matter), and have a class method <code>bitpay_client</code> with the body <code>BitPay::Client.new('mYs3cretAPIkey')</code>. </p>

<p>Anytime I do <code>BitcoinInvoice.bitpay_client.get("invoice/#{invoice_id}")</code> I get the JSON <code>{"error": "Invalid token"}</code> back from the server. In <a href="https://bitpay.com/downloads/bitpayApi.pdf" rel="nofollow">Bitpay's documentation</a> there's no mention of this message. I'm using the right api key, and I'm sure this is a real invoice. What does this message mean? </p>

<bitpay><ruby>
What does Bitpay's {"error": "Invalid token"} mean?
Martin Josefsson
# What does Bitpay's {"error": "Invalid token"} mean?

(Asked by: username_0 on 2014-09-18)

I'm creating a web app that uses Bitpay for payments. I'm writing it in ruby (but that shouldn't matter), and have a class method `bitpay_client` with the body `BitPay::Client.new('mYs3cretAPIkey')`.

Anytime I do `BitcoinInvoice.bitpay_client.get("invoice/#{invoice_id}")` I get the JSON `{"error": "Invalid token"}` back from the server. In [Bitpay's documentation](https://bitpay.com/downloads/bitpayApi.pdf) there's no mention of this message. I'm using the right api key, and I'm sure this is a real invoice. What does this message mean?

**Tags:** bitpay, ruby


---

## 1 answers

### Answer by username_0 on 2014-09-18. Score: 1 | Accepted answer

The error was my client connected to the wrong endpoint. This feature was undocumented at the time, but is now [clearly documented](https://github.com/bitpay/ruby-client#testnet-usage). Kudos to Bitpay!

> **Comments:**
> **username_1**: This isn't quite fair. First, Bitpay support was available to you for help. Second, the old API did still work if you used the right endpoint, and that was not something hardcoded into the library. Third, both the version 1 and 2 libraries are available on RubyGems. https://rubygems.org/gems/bitpay-client/  
> **username_0**: You're right, that was unfair. I beg your apologies and  made an updated answer. Thanks for providing a great service!  

---

