POST /api/models

Adds a model object for the business organization.

Authorization Roles/Permissions: Must have permission to create objects for the business organizations.

This topic includes the following sections:

HTTP Method

POST

Back to top

URL

https://{hostname}/api/models

Back to top

Sample Request

The example below shows a request to add the specified model.

Request URL

https://{hostname}/api/models

Sample request headers

Accept: application/json
Content-Type: application/json
X-Csrf-Token_acmepaymentscorp":"TokenID%3D8ed70a13-8469-11e8-b37a-b155e4eabeb8%2CexpirationTime%3D153...

Sample request body #1: creating from scratch

In the example below, the model was created from scratch, not by uploading a schema file.

{
  "Visibility":"Public",
  "BusinessID":"tenantbusiness.acmepaymentscorp",
  "Name":"Credit Card Purchase2",
  "Summary":"Credit card purchase transaction",
  "Description":"For use in multiple top-level model objects.",
  "ModelCategory":"Transaction",
  "VersionName":"v1",
  "VersionDescription":"First version"
}

Sample request body #2: creating from a schema file

In the example below, the model was created by uploading a schema file. Using the API, there are two steps:

  1. Upload the schema file to the dropbox using the POST /api/models/readfiledetails operation.
  2. Create the model using the current operation, listing the DropboxFileId in the body of the message as shown below.
{
  "Visibility":"Public",
  "BusinessID":"tenantbusiness.acmepaymentscorp",
  "ModelCategory":"global",
  "SchemaDocumentReference":{
    "DropboxFileId":1150,
    "FileName":"single-schema.json",
    "SchemaImports":[
      {
        "Name":"Pet",
        "AddToLibrary":true
      }
    ]
  }
}

Back to top

Request Headers

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

Header Description
Accept application/json
Content-Type application/json
AtmoAuthToken_{fedmemberid} The platform cookie. This is the Akana API Platform authorization token, and must be sent with every API request that requires login.
X-Csrf-Token_{fedmemberID} The CSRF prevention header; may or may not be required, depending on platform settings. See CSRF Prevention on the Platform. By default, the CSRF header is not required for GET operations and is required for all others, with a few exceptions relating to user login.

Back to top

Request Parameters

Parameter Parm Type Data Type Required Description
AddModelRequest Body AddModelRequest Required Contains information about a request to add a model object.

Back to top

Response

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

Back to top

Sample Response

The sample response below shows successful completion of this operation.

Sample response headers: application/json

HTTP/1.1 200 OK
Date: Fri, 03 May 2019 20:22:42 GMT
Content-Type: application/json

Sample response body #1: create from scratch

In this example, the model will be created from scratch. Values have been provided for some optional fields such as Description.

{
    "ModelID": "53ae7015-ecb7-4ffc-8060-a860daabb83b.acmepaymentscorp",
    "Name": "Credit Card Purchase2",
    "Description": "For use in multiple top-level model objects.",
    "Summary": "Credit card purchase transaction",
    "ModelCategory": "Transaction",
    "LatestVersionID": "3b9d385f-cfd0-4b93-bd1a-25cc2fd58762.acmepaymentscorp",
    "Visibility": "Public",
    "Created": "2019-05-03T20:22:42Z",
    "Updated": "2019-05-03T20:22:42Z",
    "State": "com.akana.model.state.draft",
    "BusinessID": "tenantbusiness.acmepaymentscorp"
}

Sample response body #2: import model file

In this example, the model will be created from an uploaded file. Values are read from the file.

{
    "ModelID": "7f8673ab-7184-4fba-acf1-9d471e6fd593.acmepaymentscorp",
    "Name": "Pet",
    "ModelCategory": "global",
    "LatestVersionID": "1a318def-c8c7-4023-bae8-e7080a4c3d77.acmepaymentscorp",
    "Visibility": "Public",
    "Created": "2019-05-10T17:38:03Z",
    "Updated": "2019-05-10T17:38:03Z",
    "State": "com.akana.model.state.draft",
    "BusinessID": "tenantbusiness.acmepaymentscorp"
}

Back to top

Response Headers

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

Header Description
Content-Type application/json

Back to top

Response Body

Name Type Description
Model Model Contains information about a model object defined at the organization level.

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. You would also get this response for any operation that requires login (almost all) if the login cookie was missing.
400

Bad request: Returned if the client sends a malformed request; for example, invalid parameters or body content.

For example, you would get this response if you specified an invalid value for ModelCategory in the request body.

500 An error occurred processing the call.

More information about Akana API Platform API error messages.

Back to top

Related Topics