// This file is autogenerated, DO NOT EDIT
// search/search-your-data/search-application-security.asciidoc:40

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