See api-docs Menu

Create an App

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



Resource URL

https://<subdomain>/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
}]

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.

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

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

OpenId Connect Sample

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 client_id and client_secret.

{
  "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
  }
}

SAML Sample

This sample request uses the SAML Custom Connector.


{
  "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"
          }
     }
}

OneLogin Access Sample

This sample request creates an App that connects to an Access Enforcement Point.

{
    "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"
    }
}

Sample Responses

See the App Resource documentation for detail on the app attributes returned via this API.

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

{
  "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

Replace sample variables indicated by {{ }} with your actual values.

Run in Postman

    Clicking Run in Postman button navigates to the page where you can fork the collection to your workspace. Forking the collection into your workspace will enable you to contribute to the source collection using pull requests. You can also view the collection in a public workspace if you like and even import a copy of the collection using the links present on the screen.

Sample Code

cURL

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

Create App

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

Have a Question?

Found a problem or a bug? Submit a support ticket.

Looking for walkthroughs or how-to guides on OneLogin's user and admin features? Check out the documentation in our Knowledge Base.

Have a product idea or request? Share it with us in our Ideas Portal.