Here is a strange conversation I just had with Twitter Ads API Sandbox while trying to add a funding instrument to my sandbox account. I’m not sure what to make of it. Seems like the API is replying with errors when it shouldn’t be, but then it’s not clear if a funding source is created or not.
Tried to create a funding instrument first try…
twurl -X POST -H ads-api-sandbox.twitter.com /1/accounts/gq13q1/funding_instruments?type=CREDIT_CARD¤cy=USD&start_time=2016-09-26T00:00:00Z
{"errors":[{"code":"MISSING_PARAMETER","message":"\"currency\" is a required parameter","parameter":"currency"},{"code":"MISSING_PARAMETER","message":"\"start_time\" is a required parameter","parameter":"start_time"}],...
Strange, I double checked the parameters. Trying again with the arguments in a different order…
twurl -X POST -H ads-api-sandbox.twitter.com /1/accounts/gq13q1/funding_instruments?start_time=2016-09-26T00:00:00Z¤cy=USD&type=CREDIT_CARD
{"errors":[{"code":"MISSING_PARAMETER","message":"\"type\" is a required parameter","parameter":"type"},{"code":"MISSING_PARAMETER","message":"\"currency\" is a required parameter","parameter":"currency"}
Same errors. Hmm, trying the endpoint’s parameters as a quoted -d argument
twurl -X POST -H ads-api-sandbox.twitter.com -d 'start_time=2016-09-26T00:00:00Z¤cy=USD&type=CREDIT_CARD' /1/accounts/gq13q1/funding_instruments
{"errors":[{"code":"INVALID","message":"An existing self-serve funding instrument was found on this account","attribute":""}],"request":{"params":{"account_id":"gq13q1","type":"CREDIT_CARD","currency":"USD","start_time":"2016-09-26T00:00:00Z"}}}
Wait, what? It got created? Let’s see, hit the GET endpoint to check
twurl -X GET -H ads-api-sandbox.twitter.com /1/accounts/gq13q1/funding_instruments | python -m json.tool
{
"data": [
{
"able_to_fund": true,
"account_id": "gq13q1",
"cancelled": false,
"created_at": "2016-09-26T17:13:41Z",
"credit_limit_local_micro": 500000000,
"credit_remaining_local_micro": null,
"currency": "USD",
"deleted": false,
"description": "(no payment method has been set up yet)",
"end_time": null,
"funded_amount_local_micro": null,
"id": "hxm92",
"io_header": null,
"paused": false,
"reasons_not_able_to_fund": [],
"start_time": "2016-09-26T17:13:41Z",
"type": "CREDIT_CARD",
"updated_at": "2016-09-26T17:13:41Z"
}
],
"data_type": "funding_instrument",
"next_cursor": null,
"request": {
"params": {
"account_id": "gq13q1"
}
},
"total_count": 1
}
This is not actually a valid funding source for a sandbox account, is it?
Our app checks for no payment method has been set up yet in the description since it appears all ad accounts start with this as the default funding source.