POST

Create an App

Use this API to create a new app based off a OneLogin connector.



Resource URL

https://<subdomain>.onelogin.com/api/2/apps

Header Parameters

Authorization

required

string

Set to bearer <access_token>.

Set <access_token> to the access token you generated using the Generate Token API.

The access token must have been generated using an API credential pair created using the scope required to call this API. This API can be called using any one of the following scopes: Manage All.

Content-Type

required

string

Set to application/json.

Request Parameters

The minimum requirement to create an app is the connector_id and a name.

For a complete list of all possible values for a given app it is recommended to do a Get App request on an app that is based of the same connector.

Also see the App Resource for general app attributes.

connector_id

required

integer

ID of the connector to base the app from.

name

required

string

The name of the app

Adding New Parameters

If the connector allows it, new parameters can be added to an app during creation. To determine if a connector supports custom parameters to be defined check the allows_new_parameters attribute on the List Connectors endpoint.

GET api/2/connectors?name=amazon&auth_method=2

[{
  "allows_new_parameters": true,
  "id": 50534,
  "name": "Amazon Web Services (AWS) Multi Role",
  "icon_url": "https://cdn-shadow.onlgn.net/images/icons/square/amazonwebservices3multirole/old_original.png?1421095823",
  "auth_method": 2
}]
```xml

<p>When allowed, any parameter that is added to the parameters object will be automatically created if it does not match a parameter name that already exists on the app.</p>

<p>For example, if the <code>employee_number</code> parameter does not exist on the app and this payload is supplied a new parameter with that name would be created.</p>

```json
{
    "parameters": {
        "employee_number": {
            "values": null,
            "default_values": null,
            "label": "Employee Number"
        }
    }
}
```xml

<h2>OpenId Connect Sample</h2>
<p>This sample request uses the Generic OpenId Connect connector. The response payload when creating an OpenId Connect app will include an SSO object which contains the apps new <b>client_id</b> and <b>client_secret</b>.</p>

```json
{
  "connector_id": 108419,
  "name": "Sample OpenId Connect App",
  "description": "",
  "visible": true,
  "policy_id": 165278,
  "configuration": {
      "login_url": "http://example.com/login",
      "redirect_uri": "http://example.com/callback",
      "access_token_expiration_minutes": 5,
      "refresh_token_expiration_minutes": 60,
      "token_endpoint_auth_method": 0,
      "oidc_application_type": 0
  }
}
```xml

<h2>SAML Sample</h2>
<p>This sample request uses the SAML Custom Connector.</p>

```json
{
  "connector_id": 110016,
  "name": "SAML Custom Connector (Advanced)",
  "description": "",
  "visible": true,
  "policy_id": 165278,
  "configuration": {
     "signature_algorithm": "SHA-1",
     "certificate_id": 170216
     },
  "parameters": {
     "saml_username": {
          "user_attribute_mappings": "email"
          }
     }
}
```xml

<h2>OneLogin Access Sample</h2>
<p>This sample request creates an App that connects to an Access Enforcement Point.</p>

```json
{
    "allow_assumed_signin": false,
    "name": "OneLogin Access Sample App",
    "connector_id": 106486,
    "auth_method": 2,
    "visible": true,
    "provisioning": {
        "enabled": false
    },
    "tab_id": 196885,
    "enforcement_point": {
        "require_sitewide_authentication": true,
        "conditions": "",
        "session_expiry_fixed": {
            "value": 20,
            "unit": "minutes"
        },
        "session_expiry_inactivity": {
            "value": 25,
            "unit": "minutes"
        },
        "permissions": "allow",
        "token": "b491c647f5e0cff854ad606722ac98342b4b0882",
        "target": "",
        "resources": [
            {
                "conditions": null,
                "is_path_regex": null,
                "permissions": "allow",
                "require_auth": false,
                "path": "/"
            }
        ],
        "context_root": "",
        "use_target_host_header": false,
        "vhost": "",
        "landing_page": "",
        "case_sensitive": false
    },
    "configuration": {
        "signature_algorithm": "SHA-1"
    }
}
```html

<h2>Sample Responses</h2>
<p>See the <a href="/api-docs/2/apps/app-resource">App Resource</a> documentation for detail on the app attributes returned via this API.</p>

<div class="tab-group">
<ul class="tab-links">
<li class="t-link status-200 active" data-tab="1">201 Created</li>
<li class="t-link status-401" data-tab="2">401 Unauthorized</li>
<li class="t-link status-422" data-tab="3">422 Unprocessable Entity</li>
</ul>
<div class="tab-views">
<div class="t-view active" data-tab="1">

On success, the full app configuration is returned. This is a sample response for an OpenId Connect app.

```json
{
  "id": 928549,
  "name": "Sample OpenId Connect App",
  "visible": true,
  "description": "",
  "notes": null,
  "icon_url": "/images/missing_connector_icon/square/old_original.png",
  "auth_method": 8,
  "policy_id": 165278,
  "provisioning": {
    "enabled": false
  },
  "allow_assumed_signin": false,
  "tab_id": null,
  "connector_id": 108419,
  "sso": {
    "client_secret": "3acdcdba4e57bbb4f0454a8729fbc4ec5c4ac327c8e1d6d60c305cc9ea5dbcd3",
    "client_id": "b5dee2e0-5cbf-0137-6e19-12c80e5197ec92920"
  },
  "configuration": {
    "redirect_uri": "http://example.com/callback",
    "refresh_token_expiration_minutes": 60,
    "login_url": "http://example.com/login",
    "oidc_encryption_key": "",
    "oidc_application_type": 0,
    "token_endpoint_auth_method": 0,
    "access_token_expiration_minutes": 5
  },
  "created_at": "2019-05-19T23:56:57Z",
  "updated_at": "2019-05-19T23:56:57Z",
  "parameters": {
    "groups": {
      "values": null,
      "user_attribute_mappings": null,
      "provisioned_entitlements": false,
      "skip_if_blank": false,
      "id": 237825,
      "default_values": null,
      "attributes_transformations": null,
      "label": "Groups",
      "user_attribute_macros": null,
      "include_in_saml_assertion": true
    }
  }
}

Typically, this error means that your Authorization header value is missing or incorrectly formatted. The Authorization header value should use this format: bearer <access_token>.

{
    "message": "Unauthorized",
    "statusCode": 401,
    "name": "UnauthorizedError"
}

Indicates that the syntax of the request is good but a value supplied is not valid.

{
    "message": "Validation failed: The associated Policy with ID 0 could not be found",
    "statusCode": 422,
    "name": "UnprocessableEntityError"
}

Postman Collection

Run In Postman

Sample Code

cURL

Replace sample values indicated by < > with your actual values.

Create App

curl 'https://<subdomain>.onelogin.com/api/2/apps' \
-X POST \
-H "Authorization: bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
  "connector_id":"<connector_id>",
  "name":"<app name>"
}'