Example: Adding an API Version

This example walks you through adding a new version to an existing API in Akana API Platform by using the platform API rather than the user interface.

This exercise assumes that you already have a valid login for Akana API Platform and are an API Admin.

Note: If you added the API, you automatically become the first API Admin. See Example: Adding an API by providing the full API definition.

Before starting, you will need:

  • A valid UserID and password for platform access.
  • The APIID for the API you want to add a version to.

To add an API version in the Akana API Platform using the API

  1. Log in via the API, POST /api/login operation, using your own email and password in the body of the operation instead of the placeholder values given below.
    • HTTP method: POST
    • URL: https://{hostname}/api/login
    • Accept header: application/json
    • Content-Type header: application/json
    • Request Body:
      {
        "email":"MyEmailAddress",
        "password":"MyPassword"
      }
  2. Add the API version, using the POST /api/apis/{APIID}/versions operation. In your API call, use the following, substituting the correct APIID in the URL and also in the request body:
    • HTTP method: POST
    • URL: https://{hostname}/api/apis/{APIID}versions
    • Accept header: application/json
    • Content-Type header: application/json
    • CSRF header: include it if needed. If you are not sure whether it's needed or not, refer to CSRF Prevention on the Platform.
    • Request Body (Key values are: valid APIID, and for the new version, Name, Description, and SandboxEndpoint; for Endpoints, CName and URI, and for target API (target URL), URI:
       { 
          "APIID":"MyAPIID",
          "Name":"Version 2",
          "Description":"Major update.",
          "Type":"shttp",
          "DefaultProfile":"Any in and out",
          "Tag":[ 
            "payments",
            "ACME"
          ],
          "ProductionEndpoint":"http://acme-payments-api.10.1.20.137:9901/",
          "SandboxEndpoint":"http://acme-payments-api.10.1.20.137:9901/",
          "Operations":{ 
            "Operation":[ 
              { 
                "Method":"GET",
                "Path":"/payments/{paymentid}",
                "Input":[ 
                  { 
                    "Name":"paymentid",
                    "Type":"path"
                  }
                ],
                "InputContentType":"*/*",
                "OutputContentType":"*/*",
                "FaultContentType":"*/*",
                "Name":"getPayment"
              },
              { 
                "Method":"GET",
                "Path":"/payments/payments",
                "Input":[ 
      
                ],
                "InputContentType":"*/*",
                "OutputContentType":"*/*",
                "FaultContentType":"*/*",
                "Name":"listPayments"
              },
              { 
                "Method":"POST",
                "Path":"/payments",
                "Input":[ 
      
                ],
                "InputContentType":"*/*",
                "OutputContentType":"*/*",
                "FaultContentType":"*/*",
                "Name":"addPayment"
              },
              { 
                "Method":"DELETE",
                "Path":"/{path:.+|}",
                "Input":[ 
                  { 
                    "Name":"path",
                    "Type":"path"
                  }
                ],
                "InputContentType":"*/*",
                "OutputContentType":"*/*",
                "FaultContentType":"*/*",
                "Name":"deletePayment"
              }
            ]
          },
          "Endpoints":{ 
            "Endpoint":[ 
              { 
                "Uri":"http://acme-payments-api.10.1.20.137:9901/",
                "Category":"Production",
                "CName":"acme-payments-api.10.1.20.137",
                "DeploymentZoneRule":"1b16623b-1609-4664-9900-06f8441bdefault-http0"
              },
              { 
                "Uri":"http://acme-payments-api.10.1.20.137:9901/",
                "Category":"Sandbox",
                "CName":"acme-payments-api.10.1.20.137",
                "DeploymentZoneRule":"1b16623b-1609-4664-9900-06f8441bdefault-http0"
              }
            ]
          },
          "TargetAPI":{ 
            "Endpoints":{ 
              "Endpoint":[ 
                { 
                  "Uri":"http://www.acmepayments.com/api",
                  "Category":"Production"
                },
                { 
                  "Uri":"http://www.acmepayments.com/apisb",
                  "Category":"Sandbox"
                }
              ]
            },
            "Type":"shttp",
            "Operations":{ 
              "Operation":[ 
                { 
                  "Method":"GET",
                  "Path":"/payments/{paymentid}",
                  "Input":[ 
                    { 
                      "Name":"paymentid",
                      "Type":"path"
                    }
                  ],
                  "InputContentType":"*/*",
                  "OutputContentType":"*/*",
                  "FaultContentType":"*/*",
                  "Name":"getPayment"
                },
                { 
                  "Method":"GET",
                  "Path":"/payments/payments",
                  "Input":[ 
      
                  ],
                  "InputContentType":"*/*",
                  "OutputContentType":"*/*",
                  "FaultContentType":"*/*",
                  "Name":"listPayments"
                },
                { 
                  "Method":"POST",
                  "Path":"/payments",
                  "Input":[ 
      
                  ],
                  "InputContentType":"*/*",
                  "OutputContentType":"*/*",
                  "FaultContentType":"*/*",
                  "Name":"addPayment"
                },
                { 
                  "Method":"DELETE",
                  "Path":"/payments/{paymentid}",
                  "Input":[ 
                    { 
                      "Name":"paymentid",
                      "Type":"path"
                    }
                  ],
                  "InputContentType":"*/*",
                  "OutputContentType":"*/*",
                  "FaultContentType":"*/*",
                  "Name":"deletePayment"
                }
              ]
            },
            "Policies":{ 
              "Policy":[ 
      
              ]
            },
            "DefaultProfile":"Any in and out"
          },
          "Visibility":"Public",
          "State":"com.soa.api.state.open",
          "ProductionEndpointAccessAutoApproved":false,
          "SandboxEndpointAccessAutoApproved":true,
          "SandboxAnonymousAccessAllowed":false,
          "ProductionAnonymousAccessAllowed":false,
          "ResourceLevelPermissionsSupported":true,
          "Policies":{ 
            "Policy":[ 
      
            ]
          }
        }
  3. You should get an HTTP 200 response, with the full version object including the newly-assigned APIVersionID.Take the APIVersionID; you will use this later.
  4. When done, remember to log out using the POST /api/login/logout operation. Use the following values:
    • URL: https://{hostname}/api/login/logout
    • Accept header: application/json
    • Content-Type header: application/x-www-form-urlencoded

Back to top

Related Topics