Invalid API Key

I cannot figure out how to get pass this on a create order API:

{"message":"Invalid API Key"}

They same key worked fine on the wallet get transactions api. I tried generating a new key, but getting the same error. What else can I try?

It’s possible you’re using the wrong api endpoint/url. I just ran into this issue trying to call functions from the exchange api when I needed to be using the Advanced Trading API

url = "https://api.exchange.coinbase.com/orders"

I get invalid key.

url = "https://api.coinbase.com/api/v3/brokerage/orders/"

I get unauthorized.

What is the correct url? Too many conflicting docs.

Is there a working sample/code out there that includes the authentication and authorization along with creating an order?

Perhaps this is a simpler question: How do I modify the stock code below to include api key authentication?

import http.client

conn = http.client.HTTPSConnection("api.coinbase.com")
payload = ''
headers = {}
conn.request("POST", "/api/v3/brokerage/orders", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Hi, @firlas , can you please share your actual request?

I may have gotten further. Can someone tell me what this error means? …or point me to the error catalog?

--------- BEGIN REQUEST ---------
POST /api/v3/brokerage/orders HTTP/1.1
Host: api.coinbase.com
Accept-Encoding: identity
Content-Length: 163
CB-ACCESS-SIGN: xxxxxxxxxxxx3441b273bcf8fd764c04e77d322181e42efaecfbc23708dc7
CB-ACCESS-TIMESTAMP: 1671298194
CB-ACCESS-KEY: xxxxxxxxxxxxxxxxxxxxx
CB-VERSION: 2022-05-10
---------- END REQUEST ----------
--------- BEGIN REQUEST ---------
{"price": "1", "size": "10", "type": "limit", "side": "BUY", "product_id": "BTC-USD", "client_order_id": "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx", "post_only": true}
---------- END REQUEST ----------
{"error":"PERMISSION_DENIED","error_details":"Source Account Not Tradable","message":"Source Account Not Tradable"}

6 days later, I’m hoping you figured it out. If not, do you have the right permissions set on your API key? For that request I believe you would want the BTC Wallet and Cash (USD) accounts enabled (or all), and the permissions should look something like this if you are going to be trading:

2 Likes

Looks like I have all those checked off:

What does “Source Account Not Tradable” mean?

ah, you were right jmicko. i had forgot to check my usd wallet. i got past that error. thank you.

1 Like