POST /api/apis

Defines an API from scratch, based on an existing service, or based on an API description document.

The API can be defined in three ways:

  • With only API name (API details to be added later)
  • Based on an existing service
  • Based on an API description document at a referenced URL or in a file (individual file or part of a ZIP file) previously uploaded to the Dropbox using the POST /api/dropbox/readfiledetails operation (Swagger 2.0, RAML, WADL, or WSDL).

To make changes to the API once you've created it, use one of the following:

New in API Platform Version: 8.1

Note: When creating an API using this API operation, you can specify deployment zones for the new API. This functionality isn't currently covered by the user interface (as of version 8.3) but is supported by the API. See Sample Request Body #6 below.

Authorization Roles/Permissions: Must have permission to add an API. The user who adds the API automatically becomes the first API Administrator.

This topic includes the following sections:

HTTP Method

POST

Back to top

URL

https://{hostname}/api/apis

Back to top

Sample Request

The examples below show several variations of adding an API by providing different optional values.

Request URL

https://{hostname}/api/apis

Sample request headers

POST /api/apis HTTP/1.1
Host: {hostname}
Accept: application/vnd.soa.v81+json
Content-Type: application/vnd.soa.v81+json; charset=UTF-8
X-Csrf-Token_{tenant}: {TokenID}

Sample request body #1

Creates an API by uploading a Swagger document, previously uploaded to the Dropbox using the POST /api/dropbox/readfiledetails operation.

{
  "DLDescriptor":{
    "ServiceDescriptorReference":{
      "ServiceName":"Swagger_Petstore",
      "FileName":"swagger_petstore.json",
      "DropboxFileId":1053
    }
  }
}

Sample request body #2

Creates an API with only the API name provided, so the API Admin can add the details later. Corresponds to the "Create API from Scratch" option in the UI. No target endpoint specified.

{
  "APIVersionInfo":{
    "Name":"ACME Payments API"
  },
  "AddAPIImplementationRequest":{
    "CreateMechanism":"PROXY"
  }
}

Sample request body #3

Creates an API with only the API name provided, so the API Admin can add the details later. Corresponds to the "Create API from Scratch" option in the UI. This example includes the optional target endpoint URL.

{
  "APIVersionInfo":{
    "Name":"ACME Payments API"
  },
  "AddAPIImplementationRequest":{
    "ProxyImplementationRequest":{
      "TargetEndpointURL":[
        "http://www.acmepayments.com/api"
      ]
    }
  }
}

Sample request body #4: Upload RAML file

Creates an API by referencing a specific RAML file previously uploaded to the Dropbox using the POST /api/dropbox/readfiledetails operation.

{
  "DLDescriptor":{
    "ServiceDescriptorReference":{
      "DropboxFileId":1024,
      "FileName":"ACMEPaymentsCorpAPI.raml",
      "ServiceName":"ACME_Payments_Corp_API"
    }
  }
}

Sample request body #5: Upload RAML file in ZIP file

Creates an API by referencing a specific RAML file in a ZIP file previously uploaded to the Dropbox using the POST /api/dropbox/readfiledetails operation.

{
  "DLDescriptor":{
    "ServiceDescriptorReference":{
      "ServiceName":"Aria_API",
      "FileName":"RAMLDocs/ACMEPaymentsCorpAPI.raml",
      "DropboxFileId":1054
    }
  }
}

Sample request body #6: Include deployment zone specifications

Specifies two deployment zones for the API.

{
  "APIVersionInfo": {
    "Name": "NewAPI_WithDZ"
  },
  "AddAPIImplementationRequest": {
    "ProxyImplementationRequest": {
      "TargetEndpointURL": "http://httpstat.us"
    },
    "APIImplementationDeployments": {
      "DeploymentZonesHostingInfo": [{
        "DeploymentZoneEndpoint": [{
          "DeploymentZoneID": "83c0f1b8-b0fb-4195-86db-e9f2a95132f5.acmepaymentscorp",
          "EndpointPath": "/",
          "Protocol": "https",
          "Public": true
        }, {
          "DeploymentZoneID": "83c0f1b8-b0fb-4195-86db-e9f2a95132f5.acmepaymentscorp",
          "Protocol": "http",
          "ListenerName": "httplistener2",
          "EndpointHostName": "acmepaymentscorp",
          "EndpointPath": "/http"
        }],
        "DeploymentZoneID": "83c0f1b8-b0fb-4195-86db-e9f2a95132f5.acmepaymentscorp"
      }]
    },
    "CreateMechanism": "PROXY"
  },
  "classifiers": {}
}

Back to top

Request Headers

For general information on request header values, refer to HTTP Request Headers.

Header Description
Accept application/vnd.soa.v81+json, application/vnd.soa.v81+xml
Content-Type

Any one of the following media types is valid for the request Content-Type:

application/vnd.soa.v81+json or application/vnd.soa.v81+xml

X-Csrf-Token_{fedmemberID} The CSRF prevention header; may or may not be required, depending on platform settings. See CSRF Prevention on the Platform.

Back to top

Request Parameters

Parameter Parm Type Data Type Required Description
addAPIRequest Body addAPIRequest Required

Contains information about a request to add an API.

The only property required is the API name.

Properties supported in the AddAPIImplementRequest (part of this object) when creating an API are:

  • ImplementationCode
  • CreateMechanism
  • ProxyImplementationRequest (if CreateMechanism is PROXY)

The DropboxFileId is returned by the POST /api/dropbox/readfiledetails operation which is run first to upload an individual or ZIP file.

Back to top

Response

If successful, this operation returns HTTP status code 200, with information about the API that was added.

Back to top

Sample Response

The sample response below shows successful completion of this operation.

Sample response headers: application/vnd.soa.v81+json

HTTP/1.1 200 OK
Date: Tue, 05 Jul 2016 14:49:13 GMT
Content-Type: application/vnd.soa.v81+json
Atmo-Renew-Token: renew
Set-Cookie: Csrf-Token_acmepaymentscorp=TokenID%3Dde5b2e6a-d040-11e5-82f9-a0de4d4...

Sample response body: application/vnd.soa.v81+json (response to sample request #3)

{
  "APIID" : "420b17dd-f733-464c-9353-8f71467c7bae.acmepaymentscorp",
  "Name" : "ACME Payments API2",
  "Description" : "ACME Payments API2",
  "Visibility" : "Public",
  "LatestVersionID" : "3fbbf104-cacd-443b-b539-f86dd545bfad.acmepaymentscorp",
  "RatingSummary" : {
    "Five" : 0,
    "Four" : 0,
    "Three" : 0,
    "Two" : 0,
    "One" : 0
  },
  "APIVersion" : {
    "APIVersionID" : "3fbbf104-cacd-443b-b539-f86dd545bfad.acmepaymentscorp",
    "APIID" : "420b17dd-f733-464c-9353-8f71467c7bae.acmepaymentscorp",
    "Name" : "v1",
    "Description" : "ACME Payments API2",
    "Environment" : "Production",
    "Visibility" : "Public",
    "Created" : "2016-07-05T14:49:15Z",
    "Updated" : "2016-07-05T14:49:15Z",
    "State" : "com.soa.api.state.open",
    "ProductionEndpointAccessAutoApproved" : false,
    "SandboxEndpointAccessAutoApproved" : false,
    "RatingSummary" : {
      "Five" : 0,
      "Four" : 0,
      "Three" : 0,
      "Two" : 0,
      "One" : 0
    },
    "SandboxAnonymousAccessAllowed" : false,
    "ProductionAnonymousAccessAllowed" : false,
    "ResourceLevelPermissionsSupported" : false,
    "APIOwnedImplementations" : true,
    "APIDesign" : {
      "CommonDesign" : false
    }
  },
  "AdminGroupID" : "apiadmin-420b17dd-f733-464c-9353-8f71467c7bae.acmepaymentscorp",
  "Created" : "2016-07-05T14:49:15Z",
  "Updated" : "2016-07-05T14:49:15Z"
}

Back to top

Response Headers

For general information on response header values, refer to HTTP Response Headers.

Header Description
Content-Type application/vnd.soa.v81+json, application/vnd.soa.v81+xml
Atmo-Renew-Token renew

Back to top

Response Body

Name Type Description
API API Includes information about an API.

Back to top

Error Codes/Messages

If the call is unsuccessful an error code/message is returned. One or more examples of possible errors for this operation are shown below.

Item Value
401 Unauthorized. For example, you would get this response if you didn't include the custom X-Csrf-Token_{fedmemberID} header in the request, when it was required by the platform settings; or if you included an invalid or expired value for this header.
500 An error occurred processing the call.

More information about Akana API Platform API error messages.

Back to top

Related Topics