GitHub API v3 failing to post Deploy Keys

Working on a Bash script to automate Deploy Key rotations, and I am regularly getting a Unicorn! · GitHub response.  Here is the command I am running:

function push_ssh_key() {

  local KEY_CONTENT="$(cat /root/.ssh/id_rsa_${1}_${DATE}.pub)"

  local JSON="{“title”: “${1}_${DATE}”, “key”: “${KEY_CONTENT}”, “read_only”: true}"

  curl \

    --header “Authorization: token <my_access_token>” \

    --header “Accept: application/vnd.github.v3+json” &nbsp; # application/json also fails

    --request POST \

    --data “$JSON” \



DATE is set globally for other functions to reference

push_ssh_key “repository_a”

I can verify that the JSON I am passing to the URL is proper JSON:

{“title”: “repository_a_2018-12-31”, “key”: “ssh-rsa AAAAB3Nz…”, “read_only”: true}

As far as I can tell, I am following everything according to the docs

What am I missing?  

Hey @daytonpa,

Thank you for being here! Could you please send us the full output of a curl -v request that demonstrates the problem?

That should help us investigate the issue. Also, please make sure you mask any sensitive information like OAuth tokens and Authorization headers in the output of the curl command. Please send the output to And include a link to this thread to give support some background on the ticket.

I hope this helps!


Hi @daytonpa,

When you say that you are regularly getting a unicorn response, does that mean that you are getting a unicorn response every time or just a large part of the time? Do you ever get a different response?