Error creating new API through Dashboard REST API


I need help figuring out how how to create an API. I’m new to Tyk and installed the on-prem Pro version with the Vagrant instructions. I’m trying to create an API through the Dashboard REST API following this tutorial:

I used cURL to send an almost identical request as shown in the tutorial, changing only things like API name, and API key (which I got through the dashboard for the example generated user as instructed in the tutorials). I get this error:

“Message”: “API object validation failed, most likely malformed input”,
“Meta”: null,
“Status”: “Error”

My example request follows:

curl -H “Authorization: a768f533927f41c065c9db703cc88070”
-H “Content-Type: application/json”
-d ‘{
“api_definition”: {
“name”: “My API Test”,
“slug”: “myapi-test-api”,
“auth”: {
“auth_header_name”: “Authorization”
“definition”: {
“location”: “header”,
“key”: “x-api-version”
“version_data”: {
“not_versioned”: true,
“versions”: {
“Default”: {
“name”: “Default”,
“use_extended_paths”: true
“proxy”: {
“listen_path”: “/myapi_test/”,
“target_url”: “”,
“strip_listen_path”: true
“active”: true
}’ http://localhost:3000/api/apis/ | python -mjson.tool

Thanks for any help you can provide.

Sometimes copying and pasting the commands causes the JSON object to become invalid, there’s a nicer form you can use:

1. Create a file called my-api.json

2. Add the API object to it (remove the back slashes):

	"api_definition": {
		"name": "My API Test",
		"slug": "myapi-test-api",
		"auth": {
			"auth_header_name": "Authorization"
		"definition": {
			"location": "header",
			"key": "x-api-version"
		"version_data": {
			"not_versioned": true,
			"versions": {
				"Default": {
					"name": "Default",
					"use_extended_paths": true
		"proxy": {
			"listen_path": "/myapi_test/",
			"target_url": "",
			"strip_listen_path": true
		"active": true

(I tend to run the JSON through something like to make sure it’s ok)

3. Then use the curl file form:

curl -H "Authorization: a768f533927f41c065c9db703cc88070" -s -H "Content-Type: application/json" -X POST -d @my-api.json http://localhost:3000/api/apis/ | python -mjson.tool

That should remove validation issues and make it easier to edit/test/repeat.

Thanks for the quick reply. It worked following your approach.

1 Like