Add API
post
/mobile/tools/1.0/apis
Creates an API definition.
Request
Supported Media Types
- application/json
Body Parameter
The API representation for POST requests.
Root Schema : apiCreate
Type:
object
The API representation for POST requests.
-
Type:
object
assetCreateAdditional Properties Allowed:The asset representation for POST requests. -
Type:
object
apiCreate-allOf[1]Additional Properties Allowed:
Nested Schema : assetCreate
Type:
object
The asset representation for POST requests.
-
Type:
object
assetUpdateAdditional Properties Allowed:The asset representation for PUT requests. -
Type:
object
assetCreate-allOf[1]Additional Properties Allowed:
Nested Schema : apiCreate-allOf[1]
- apiDefn
-
Type:
array
stringArrayAdditional Properties Allowed:Minimum Number of Items:0
An array of string values. - basePath
-
Type:
string
The API base path in the format `/mobile/custom/{apiName}`. This is required to define the API name. - businessObjectsDefn
-
Type:
string
- hasBusinessObjects
-
Type:
boolean
Default Value:false
Indicates whether the API is associated with API Express resources (business objects). - icon
-
Type:
object
iconAdditional Properties Allowed:Information about the icon that's associated with the API or connector. - security
-
Type:
object
apiSecurityAdditional Properties Allowed:The API security for POST and PUT requests.
Nested Schema : assetUpdate
Type:
object
The asset representation for PUT requests.
- actionComment
-
Type:
string
- desc
-
Type:
string
Maximum Length:100
- max
-
Type:
boolean
Default Value:false
- name
-
Type:
string
Required:true
Maximum Length:100
Pattern:^[a-zA-Z][a-zA-Z0-9_]*$
- namespace
-
Type:
string
Applicable to APIs and implementations only. This value is null for all other asset types. - title
-
Type:
string
Maximum Length:255
- version
-
Type:
string
Maximum Length:100
Pattern:^[a-zA-Z0-9][\w.]*$
Asset version.
Nested Schema : assetCreate-allOf[1]
- max
-
Type:
boolean
Default Value:false
Nested Schema : stringArray
Nested Schema : icon
Type:
object
Information about the icon that's associated with the API or connector.
- id
-
Type:
string
Required:true
- url
-
Type:
string
Required:true
Nested Schema : apiSecurity
Type:
object
The API security for POST and PUT requests.
- access
-
Type:
object
securityAccessAdditional Properties Allowed:Access details. - endpoints
-
Type:
array
endpointSecurityArrayAdditional Properties Allowed:Minimum Number of Items:0
An array of endpoint security elements. - loginType
-
Allowed Values:
[ "ENTERPRISE", "IDENTITYPROVIDER" ]
If the `required` attribute has a value of `true`, then the default is `ENTERPRISE`. - required
-
Type:
boolean
Required:true
When `true`, either security access or a social identity provider configuration is required.
Nested Schema : securityAccess
Type:
object
Access details.
- all
-
Type:
boolean
- roles
-
Type:
array
stringArrayAdditional Properties Allowed:Minimum Number of Items:0
An array of string values.
Nested Schema : endpointSecurityArray
Type:
array
Minimum Number of Items:
0
An array of endpoint security elements.
-
Type:
object
endpointSecurityAdditional Properties Allowed:The API security for POST and PUT requests.
Nested Schema : endpointSecurity
Type:
object
The API security for POST and PUT requests.
- access
-
Type:
object
securityAccessAdditional Properties Allowed:Access details. - method
-
Type:
string
Required:true
- resource
-
Type:
string
Required:true
Response
Supported Media Types
- application/json
201 Response
The API was created, and the metadata for the new API was returned.
Headers
- ETag
-
Type:
string
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. - Location
-
Type:
string
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.
-
Type:
object
apiShortAdditional Properties Allowed:The short API definition representation. -
Type:
object
apiCreatedWithRamlValidation-allOf[1]Additional Properties Allowed:
Nested Schema : apiShort
Type:
object
The short API definition representation.
-
Type:
object
assetGetAdditional Properties Allowed:The asset representation for GET requests. -
Type:
object
apiShort-allOf[1]Additional Properties Allowed:
Nested Schema : apiCreatedWithRamlValidation-allOf[1]
- ramlValidationReport
-
Type:
object
ramlValidationReportAdditional Properties Allowed:The result of the RAML validation. - security
-
Type:
object
apiSecurityAdditional Properties Allowed:The API security for POST and PUT requests.
Nested Schema : assetGet
Type:
object
The asset representation for GET requests.
-
Type:
object
assetUpdateAdditional Properties Allowed:The asset representation for PUT requests. -
Type:
object
assetIdEtagAdditional Properties Allowed:The asset ID and entity tag (ETag) values. -
Type:
object
trashAdditional Properties Allowed:Indicator of whether the asset is in the trash. -
Type:
object
assetGet-allOf[3]Additional Properties Allowed:
Nested Schema : apiShort-allOf[1]
- basePath
-
Type:
string
The API base path in the format `/mobile/custom/{apiName}`. - hasBusinessObjects
-
Type:
boolean
Default Value:false
Indicates whether the API is associated with API Express resources (business objects). - icon
-
Type:
object
iconAdditional Properties Allowed:Information about the icon that's associated with the API or connector.
Nested Schema : assetUpdate
Type:
object
The asset representation for PUT requests.
- actionComment
-
Type:
string
- desc
-
Type:
string
Maximum Length:100
- max
-
Type:
boolean
Default Value:false
- name
-
Type:
string
Required:true
Maximum Length:100
Pattern:^[a-zA-Z][a-zA-Z0-9_]*$
- namespace
-
Type:
string
Applicable to APIs and implementations only. This value is null for all other asset types. - title
-
Type:
string
Maximum Length:255
- version
-
Type:
string
Maximum Length:100
Pattern:^[a-zA-Z0-9][\w.]*$
Asset version.
Nested Schema : assetIdEtag
Type:
object
The asset ID and entity tag (ETag) values.
- etag
-
Type:
string
The asset entity tag (ETag) value, which you can use to detect concurrent modification. - id
-
Type:
string
Required:true
Nested Schema : trash
Nested Schema : assetGet-allOf[3]
- createdOn
-
Type:
string
- deletedBy
-
Type:
string
- deletedOn
-
Type:
string
- links
-
Type:
array
entityLinksArrayAdditional Properties Allowed:Minimum Number of Items:0
An array of links for an entity's metadata. - modifiedBy
-
Type:
string
- modifiedOn
-
Type:
string
- published
-
Type:
boolean
An asset draft or published status representation.
Nested Schema : entityLinksArray
Nested Schema : items
Type:
object
Link to the entity's metadata.
- href
-
Type:
string
Required:true
Link value. - rel
-
Required:
true
Allowed Values:[ "self", "canonical" ]
Link type.
Nested Schema : icon
Type:
object
Information about the icon that's associated with the API or connector.
- id
-
Type:
string
Required:true
- url
-
Type:
string
Required:true
Nested Schema : ramlValidationReport
Type:
object
The result of the RAML validation.
- valid
-
Type:
boolean
Required:true
- validationResults
-
Type:
array
validationResultsAdditional Properties Allowed:Minimum Number of Items:0
Nested Schema : apiSecurity
Type:
object
The API security for POST and PUT requests.
- access
-
Type:
object
securityAccessAdditional Properties Allowed:Access details. - endpoints
-
Type:
array
endpointSecurityArrayAdditional Properties Allowed:Minimum Number of Items:0
An array of endpoint security elements. - loginType
-
Allowed Values:
[ "ENTERPRISE", "IDENTITYPROVIDER" ]
If the `required` attribute has a value of `true`, then the default is `ENTERPRISE`. - required
-
Type:
boolean
Required:true
When `true`, either security access or a social identity provider configuration is required.
Nested Schema : validationResults
Nested Schema : securityAccess
Type:
object
Access details.
- all
-
Type:
boolean
- roles
-
Type:
array
stringArrayAdditional Properties Allowed:Minimum Number of Items:0
An array of string values.
Nested Schema : endpointSecurityArray
Type:
array
Minimum Number of Items:
0
An array of endpoint security elements.
-
Type:
object
endpointSecurityAdditional Properties Allowed:The API security for POST and PUT requests.
Nested Schema : stringArray
Nested Schema : endpointSecurity
Type:
object
The API security for POST and PUT requests.
- access
-
Type:
object
securityAccessAdditional Properties Allowed:Access details. - method
-
Type:
string
Required:true
- resource
-
Type:
string
Required:true
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
- detail
-
Type:
string
Required:true
Message that provides the error details. - o:ecid
-
Type:
string
Required:true
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components. - o:errorCode
-
Type:
string
Required:true
The service's error code. - o:errorDetails
-
Type:
object
errorDetailsAdditional Properties Allowed: - o:errorPath
-
Type:
string
Required:true
The relative point in the API path where the error occurred. - status
-
Type:
integer
(int64
)Required:true
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details. - title
-
Type:
string
Required:true
Summary of the problem. - type
-
Type:
string
Required:true
The URI to the link that provides details about the HTTP status code.
Nested Schema : errorDetails
Type:
object
- detail
-
Type:
string
Required:true
- o:errorDetails
-
Type:
object
errorDetailsAdditional Properties Allowed: - title
-
Type:
string
Required:true
Summary of the problem. - type
-
Type:
string
Required:true
The URI to the link that provides details about the HTTP status code.
409 Response
An API with the same name and version already exists.
Body
Root Schema : error
Type:
object
- detail
-
Type:
string
Required:true
Message that provides the error details. - o:ecid
-
Type:
string
Required:true
Execution context ID, which is a unique identifier to correlate events or requests that are associated with the same transaction across several components. - o:errorCode
-
Type:
string
Required:true
The service's error code. - o:errorDetails
-
Type:
object
errorDetailsAdditional Properties Allowed: - o:errorPath
-
Type:
string
Required:true
The relative point in the API path where the error occurred. - status
-
Type:
integer
(int64
)Required:true
HTTP status code. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more details. - title
-
Type:
string
Required:true
Summary of the problem. - type
-
Type:
string
Required:true
The URI to the link that provides details about the HTTP status code.
Nested Schema : errorDetails
Type:
object
- detail
-
Type:
string
Required:true
- o:errorDetails
-
Type:
object
errorDetailsAdditional Properties Allowed: - title
-
Type:
string
Required:true
Summary of the problem. - type
-
Type:
string
Required:true
The URI to the link that provides details about the HTTP status code.
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": [] } }