Gitlab api - create tag

Following the official document to create tags via api, I target on (gitlab cloud)

I can get tags with below command

curl ‘<replace_with_id>/repository/tags’ --header ‘PRIVATE-TOKEN: xxxx’

but I can’t create tag

curl --request POST ‘<replace_with_id>/repository/tags?tag_name=0.0.1&ref=master’ --header ‘PRIVATE-TOKEN: xxxx’

I always get this error

{"message":"Target master is invalid"}

I change the branch name to commit id, get similar error.

{"message":"Target 5db1xxxx is invalid"}

Does gitlab cloud support this API?

I just ran into the same issue.
I had data from different request stored and the create tag request was trying to use it, which caused the error.