// This file is autogenerated, DO NOT EDIT
// rest-api/security/create-api-keys.asciidoc:226

[source, python]
----
resp = client.security.create_api_key(
    name="my-restricted-api-key",
    role_descriptors={
        "my-restricted-role-descriptor": {
            "indices": [
                {
                    "names": [
                        "my-search-app"
                    ],
                    "privileges": [
                        "read"
                    ]
                }
            ],
            "restriction": {
                "workflows": [
                    "search_application_query"
                ]
            }
        }
    },
)
print(resp)
----
