Add API

post

/mobile/tools/1.0/apis

Creates an API definition.

Request

Supported Media Types
Body ()
The API representation for POST requests.
Root Schema : apiCreate
Type: object
The API representation for POST requests.
Match All
Show Source
Nested Schema : assetCreate
Type: object
The asset representation for POST requests.
Match All
Show Source
Nested Schema : apiCreate-allOf[1]
Type: object
Show Source
Nested Schema : assetUpdate
Type: object
The asset representation for PUT requests.
Show Source
Nested Schema : assetCreate-allOf[1]
Type: object
Show Source
Nested Schema : stringArray
Type: array
Minimum Number of Items: 0
An array of string values.
Show Source
Nested Schema : icon
Type: object
Information about the icon that's associated with the API or connector.
Show Source
Nested Schema : apiSecurity
Type: object
The API security for POST and PUT requests.
Show Source
Nested Schema : securityAccess
Type: object
Access details.
Show Source
Nested Schema : endpointSecurityArray
Type: array
Minimum Number of Items: 0
An array of endpoint security elements.
Show Source
Nested Schema : endpointSecurity
Type: object
The API security for POST and PUT requests.
Show Source

Response

Supported Media Types

201 Response

The API was created, and the metadata for the new API was returned.
Headers
  • The ETag corresponds to the state of the API (that is, the value increments by one on each change operation). You can use this ETag with the `If-Match` HTTP header on a request.
  • URL to get the details about the new APIs.
Body ()
Information about the API (short form) and the RAML-validation result. This information doesn't include the RAML descriptor.
Root Schema : apiCreatedWithRamlValidation
Type: object
Information about the API (short form) and the RAML-validation result. This information doesn't include the RAML descriptor.
Match All
Show Source
Nested Schema : apiShort
Type: object
The short API definition representation.
Match All
Show Source
Nested Schema : apiCreatedWithRamlValidation-allOf[1]
Type: object
Show Source
Nested Schema : assetGet
Type: object
The asset representation for GET requests.
Match All
Show Source
Nested Schema : apiShort-allOf[1]
Type: object
Show Source
Nested Schema : assetUpdate
Type: object
The asset representation for PUT requests.
Show Source
Nested Schema : assetIdEtag
Type: object
The asset ID and entity tag (ETag) values.
Show Source
Nested Schema : trash
Type: object
Indicator of whether the asset is in the trash.
Show Source
Nested Schema : assetGet-allOf[3]
Type: object
Show Source
Nested Schema : entityLinksArray
Type: array
Minimum Number of Items: 0
An array of links for an entity's metadata.
Show Source
Nested Schema : items
Type: object
Link to the entity's metadata.
Show Source
Nested Schema : icon
Type: object
Information about the icon that's associated with the API or connector.
Show Source
Nested Schema : ramlValidationReport
Type: object
The result of the RAML validation.
Show Source
Nested Schema : apiSecurity
Type: object
The API security for POST and PUT requests.
Show Source
Nested Schema : validationResults
Type: array
Minimum Number of Items: 0
Show Source
Nested Schema : securityAccess
Type: object
Access details.
Show Source
Nested Schema : endpointSecurityArray
Type: array
Minimum Number of Items: 0
An array of endpoint security elements.
Show Source
Nested Schema : stringArray
Type: array
Minimum Number of Items: 0
An array of string values.
Show Source
Nested Schema : endpointSecurity
Type: object
The API security for POST and PUT requests.
Show Source

400 Response

The API metadata is missing information (for example, the API specification is missing) or it has incorrect data (the RAML can't be parsed). In the case of an incorrect RAML, send a request to POST /apis/raml to get RAML validation details.
Body ()
Root Schema : error
Type: object
Show Source
Nested Schema : errorDetails
Type: object
Show Source

409 Response

An API with the same name and version already exists.
Body ()
Root Schema : error
Type: object
Show Source
Nested Schema : errorDetails
Type: object
Show Source

Examples

The following example shows how to add an API using cURL. For more information about cURL, see Use cURL.

curl -i -X POST -d @body.json -H "Content-Type: application/json; charset=utf-8" -H "Authorization: Bearer $TOKEN" "$BASE_URL/mobile/tools/1.0/apis"

Example of Request Body

The following shows an example of a request body that contains the required properties, which are version, desc, and apiDefn. The values were obtained from the response body of a POST /mobile/tools/1.0/apis/raml request.

{
    "version": "1.0",
    "desc": "Message of the Day API",
    "apiDefn": [
        "#%RAML 0.8\r",
        "title: Message of the Day\r",
        "version: 1.0\r",
        "baseUri: /mobile/custom/motd\r",
        "schemas:\r",
        "  - motd: | \r",
        "      {\r",
        "        \"id\": \"motd\",\r",
        "        \"$schema\": \"http://json-schema.org/draft-04/schema#\",\r",
        "        \"title\": \"The message of the day.\",\r",
        "        \"type\": \"object\",\r",
        "        \"properties\": {\r",
        "          \"message\": {\r",
        "            \"description\":\"The message string.\",\r",
        "            \"type\": \"string\"\r",
        "          }\r",
        "        }\r",
        "      }\r",
        "           \r",
        "/motd:\r",
        "  description: \"Message to display on the home page.\"\r",
        "  get:\r",
        "    description: \"Returns the message of the day.\"\r",
        "    responses:\r",
        "      200:\r",
        "        description: \"The information was retrieved successfully.\"\r",
        "        body: \r",
        "          application/json: \r",
        "            schema: motd\r",
        "            example: | \r",
        "              {\r",
        "                \"message\": \"Happy Monday!\"\r",
        "              }"
    ]
}

Example of Response Header

The following shows an example of the response headers:

200 CREATED
Content-Length: 1700
Content-Type: application/json
Date: Thurs, 19 Oct 2017 23:56:59 GMT
Etag: "1"

Example of Response Body

The following example shows the contents of the response body in JSON format:

{
    "id": "1f014f2f-700c-4ef9-889a-4be803923720",
    "namespace": "custom",
    "name": "motd",
    "version": "1.0",
    "desc": "Message of the Day API",
    "links": [
        {
            "rel": "canonical",
            "href": "/mobile/tools/1.0/apis/1f014f2f-700c-4ef9-889a-4be803923720"
        },
        {
            "rel": "purgeDependencies",
            "href": "/mobile/tools/1.0/assets/purgeDependencies"
        },
        {
            "rel": "purging",
            "href": "/mobile/tools/1.0/assets/purging"
        },
        {
            "rel": "trashDependencies",
            "href": "/mobile/tools/1.0/assets/trashDependencies"
        },
        {
            "rel": "trashing",
            "href": "/mobile/tools/1.0/assets/trashing"
        },
        {
            "rel": "untrashDependencies",
            "href": "/mobile/tools/1.0/assets/untrashDependencies"
        },
        {
            "rel": "untrashing",
            "href": "/mobile/tools/1.0/assets/untrashing"
        },
        {
            "rel": "dependencies",
            "href": "/mobile/tools/1.0/apis/1f014f2f-700c-4ef9-889a-4be803923720/dependencies"
        },
        {
            "rel": "history",
            "href": "/mobile/tools/1.0/apis/1f014f2f-700c-4ef9-889a-4be803923720/history"
        },
        {
            "rel": "publication",
            "href": "/mobile/tools/1.0/apis/1f014f2f-700c-4ef9-889a-4be803923720/publication"
        },
        {
            "rel": "reverseDependencies",
            "href": "/mobile/tools/1.0/apis/1f014f2f-700c-4ef9-889a-4be803923720/reverseDependencies"
        },
        {
            "rel": "implementations",
            "href": "/mobile/tools/1.0/apis/1f014f2f-700c-4ef9-889a-4be803923720/implementations"
        },
        {
            "rel": "self",
            "href": "/mobile/tools/1.0/apis"
        }
    ],
    "published": false,
    "inTrash": false,
    "actionComment": null,
    "etag": "1",
    "createdOn": "2017-10-04T23:57:02.026Z",
    "modifiedOn": "2017-10-04T23:57:02.026Z",
    "modifiedBy": "jdoe",
    "deletedOn": null,
    "deletedBy": null,
    "title": "Message of the Day",
    "basePath": "/mobile/custom/motd",
    "icon": null,
    "category": "CUSTOM",
    "hasBusinessObjects": false,
    "ramlValidationReport": {
        "validationResults": [],
        "valid": true
    },
    "security": {
        "required": false,
        "loginType": null,
        "access": null,
        "endpoints": []
    }
}