# Cloudflare

### Registering an account for Cloudflare in MechCloud OIDC Proxy

Once you have deployed [MechCloud OIDC proxy](https://github.com/mechcloud/mechcloud-oidc-proxy) in your `Cloudflare` account, you will need to add an account for `Cloudflare` before using the REST Agent for managing your Cloudflare account resources. Here is the curl command to register a Cloudflare account in MechCloud OIDC proxy -

```
curl --location 'https://<oidc_proxy_custom_domain>/api/accounts' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <mechcloud_jwt_token>' \
--data '{
    "id": "cloudflare_account1",
    "auth": {
        "type": "bearer",
        "token": "<cloudflare_api_token>"
    }
}'
```

Above command requires a MechCloud jwt token which can be generated by logging into MechCloud [console](https://portal.mechcloud.io) and then opening <https://portal.mechcloud.io/oauth2/auth1> link in the same or a different tab. Instructions for getting Cloudflare API token are there in the MechCloud OIDC proxy readme file. Make sure that the generated Cloudflare API token is having permissions for the action you are going to perform using the REST Agent. You can find permission(s) required for a Cloudflare API operation on the [new Cloudflare API documentation site](https://developers.cloudflare.com/api).

<figure><img src="https://3435649067-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQGHt89wn8Cn0pcK36Wir%2Fuploads%2FRoIXdSP3Ps5TTYXSGptB%2Fimage.png?alt=media&#x26;token=20173081-2037-4da2-9029-0c921acb9e83" alt=""><figcaption></figcaption></figure>

### Registering above account in MechCloud

Follow the instructions under [#registering-rest-api-account-in-mechcloud](https://docs.mechcloud.io/ai-agents/rest-agent/..#registering-rest-api-account-in-mechcloud "mention") section to register the account created above in MechCloud.

### Prompts for Supported Operations

#### <mark style="color:purple;">Accounts</mark>

<mark style="color:orange;">**Listing accounts**</mark>

```
list all the accounts
```

<mark style="color:purple;">**Custom Lists**</mark>

<mark style="color:orange;">**Listing custom lists under an account**</mark>

```
show all lists under '<account_id>' account
```

<mark style="color:orange;">**Listing all items under a custom list**</mark>

```
show all items under '<list_id>' list of '<account_id>' account
```

<mark style="color:orange;">**Adding items uner a custom list**</mark>

```
Replace all items under '<list_id>' list of '<account_id>' account with following items. each line below contains an ip address and associated comment separated by | -

@CURRENT_IP | Office
some_other_ip | system1
```

`CURRENT_IP` is a special variable which will be replaced with the ip of the machine where this prompt will be executed from.

### References

| Title                            | Links                                                                                                                                                 |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| New Cloudflare API Docs          | <https://developers.cloudflare.com/api-next/>                                                                                                         |
| Cloudflare API Token Permissions | [https://developers.cloudflare.com/fundamentals/api/reference/permissions](https://developers.cloudflare.com/fundamentals/api/reference/permissions/) |
