Create or update an API

POST {{baseUrl}}/apis/:owner/:api?isPrivate=false&version=adipisicing aliquip in tempor&force=false

Use this operation to create a new API or update an existing API by uploading its OpenAPI definition in YAML or JSON format. The authenticating user must have permissions to create or update APIs in the specified owner account.

The API name and version must follow SwaggerHub naming rules, otherwise the request will be rejected. Refer to:

When a new version of an existing API is created, it is not automatically made the default version. You can use PUT /apis/{owner}/{api}/settings/default to set the default version.

cURL example

Line breaks are added for readability.

curl -X POST "https://api.swaggerhub.com/apis/OWNER/API_TO_CREATE_OR_UPDATE"
     -H "Authorization: SWAGGERHUB_API_KEY"
     -H "Content-Type: application/yaml"
     --data-binary @C:\work\swagger.yaml

Note: Use --data-binary (not -d) when uploading YAML files using cURL, and remember to specify the correct Content-Type header.

Request Params

KeyDatatypeRequiredDescription
isPrivatebooleanWhether to make the API private (true) or public (false)
versionstringAPI version to create or update. If omitted, the version is extracted from the info.version field of the provided OpenAPI definition.

Either the version parameter or the info.version value must be specified, otherwise the request will be rejected. If both are specified, the version parameter overrides the info.version value.

If this API version already exists, it will be updated with the new definition (unless that version has been published - in this case the update will be rejected). | | force | boolean | | Force update |

Request Body

["{", "\n", " ", " ", "\"", "s", "w", "a", "g", "g", "e", "r", "\"", ":", " ", "\"", "2", ".", "0", "\"", ",", "\n", " ", " ", "\"", "i", "n", "f", "o", "\"", ":", " ", "{", "\n", " ", " ", " ", " ", "\"", "t", "i", "t", "l", "e", "\"", ":", " ", "\"", "S", "a", "m", "p", "l", "e", " ", "A", "P", "I", "\"", ",", "\n", " ", " ", " ", " ", "\"", "v", "e", "r", "s", "i", "o", "n", "\"", ":", " ", "\"", "1", ".", "0", ".", "0", "\"", "\n", " ", " ", "}", ",", "\n", " ", " ", "\"", "p", "a", "t", "h", "s", "\"", ":", " ", "{", "}", "\n", "}", "\n"]

HEADERS

KeyDatatypeRequiredDescription
Content-Typestring

RESPONSES

status: Created

""