|
| 1 | +--- |
| 2 | +id: 4e92423fc9126a22af2b0c37825d4195 |
| 3 | +url: create-api-tokens |
| 4 | +title: Create an API token |
| 5 | +description: In this video, learn the difference between account and user API tokens how to create one. |
| 6 | +products: |
| 7 | + - fundamentals |
| 8 | +thumbnail: |
| 9 | + url: https://pub-d9bf66e086fb4b639107aa52105b49dd.r2.dev/API%20token.png |
| 10 | +transcript: | |
| 11 | + WEBVTT |
| 12 | +
|
| 13 | + 1 |
| 14 | + 00:00:00.160 --> 00:00:04.600 |
| 15 | + An API token allows secure, |
| 16 | + fine grained access to specific resources |
| 17 | +
|
| 18 | + 2 |
| 19 | + 00:00:04.600 --> 00:00:07.080 |
| 20 | + without exposing your full account |
| 21 | + credentials. |
| 22 | +
|
| 23 | + 3 |
| 24 | + 00:00:07.080 --> 00:00:10.080 |
| 25 | + They have a limited lifespan and expire |
| 26 | + automatically. |
| 27 | +
|
| 28 | + 4 |
| 29 | + 00:00:10.640 --> 00:00:12.760 |
| 30 | + This reduces risk if they are compromised. |
| 31 | +
|
| 32 | + 5 |
| 33 | + 00:00:12.760 --> 00:00:17.280 |
| 34 | + For example, if you want to grant someone |
| 35 | + access to specific apps or data. |
| 36 | +
|
| 37 | + 6 |
| 38 | + 00:00:17.440 --> 00:00:19.440 |
| 39 | + You can create an API token for them. |
| 40 | +
|
| 41 | + 7 |
| 42 | + 00:00:19.760 --> 00:00:23.600 |
| 43 | + There are two types of tokens user token and |
| 44 | + account token. |
| 45 | +
|
| 46 | + 8 |
| 47 | + 00:00:23.600 --> 00:00:27.080 |
| 48 | + User tokens are directly tied to an |
| 49 | + individual and their account. |
| 50 | +
|
| 51 | + 9 |
| 52 | + 00:00:27.280 --> 00:00:31.240 |
| 53 | + While account tokens are typically tied to |
| 54 | + services which can help prevent an |
| 55 | +
|
| 56 | + 10 |
| 57 | + 00:00:31.240 --> 00:00:32.640 |
| 58 | + interruption in service. |
| 59 | +
|
| 60 | + 11 |
| 61 | + 00:00:32.680 --> 00:00:34.840 |
| 62 | + If an employee leaves their organization. |
| 63 | +
|
| 64 | + 12 |
| 65 | + 00:00:34.960 --> 00:00:39.080 |
| 66 | + In this video, we'll walk through how to |
| 67 | + create an API token in the Cloudflare |
| 68 | +
|
| 69 | + 13 |
| 70 | + 00:00:39.080 --> 00:00:43.080 |
| 71 | + dashboard. Before you begin, |
| 72 | + make sure you know your account and zone IDs. |
| 73 | +
|
| 74 | + 14 |
| 75 | + 00:00:43.080 --> 00:00:46.400 |
| 76 | + So let's do that. First, |
| 77 | + the account ID identifies your Cloudflare |
| 78 | +
|
| 79 | + 15 |
| 80 | + 00:00:46.400 --> 00:00:50.840 |
| 81 | + account, while the zone ID identifies a |
| 82 | + specific domain you've added to Cloudflare. |
| 83 | +
|
| 84 | + 16 |
| 85 | + 00:00:51.000 --> 00:00:55.080 |
| 86 | + From the accounts page, |
| 87 | + locate your account at the end of the account |
| 88 | +
|
| 89 | + 17 |
| 90 | + 00:00:55.080 --> 00:00:58.240 |
| 91 | + row, open the menu and select Copy Account |
| 92 | + ID. |
| 93 | +
|
| 94 | + 18 |
| 95 | + 00:00:58.560 --> 00:01:01.200 |
| 96 | + If you only have one account, |
| 97 | + it looks a little bit different. |
| 98 | +
|
| 99 | + 19 |
| 100 | + 00:01:01.400 --> 00:01:05.860 |
| 101 | + Login and go to the account home page next to |
| 102 | + your account name, |
| 103 | +
|
| 104 | + 20 |
| 105 | + 00:01:05.860 --> 00:01:08.220 |
| 106 | + select the menu button from the drop down. |
| 107 | +
|
| 108 | + 21 |
| 109 | + 00:01:08.220 --> 00:01:13.340 |
| 110 | + Choose Copy Account ID to find your zone ID, |
| 111 | + log in and go to the accounts page. |
| 112 | +
|
| 113 | + 22 |
| 114 | + 00:01:13.900 --> 00:01:17.180 |
| 115 | + Select your account, then go to the overview |
| 116 | + page for your domain. |
| 117 | +
|
| 118 | + 23 |
| 119 | + 00:01:18.060 --> 00:01:20.580 |
| 120 | + Scroll to the API section near the bottom. |
| 121 | +
|
| 122 | + 24 |
| 123 | + 00:01:20.980 --> 00:01:24.460 |
| 124 | + Here you'll see the zone ID and an option to |
| 125 | + click to copy. |
| 126 | +
|
| 127 | + 25 |
| 128 | + 00:01:25.300 --> 00:01:28.500 |
| 129 | + This section also lists your account ID for |
| 130 | + convenience. |
| 131 | +
|
| 132 | + 26 |
| 133 | + 00:01:28.940 --> 00:01:32.620 |
| 134 | + Now we can create an API token to create a |
| 135 | + token. |
| 136 | +
|
| 137 | + 27 |
| 138 | + 00:01:32.660 --> 00:01:34.420 |
| 139 | + Start from the Cloudflare dashboard. |
| 140 | +
|
| 141 | + 28 |
| 142 | + 00:01:34.620 --> 00:01:38.220 |
| 143 | + For a user token, go to profile API tokens. |
| 144 | +
|
| 145 | + 29 |
| 146 | + 00:01:39.220 --> 00:01:43.580 |
| 147 | + For an account token, |
| 148 | + go to Manage Account account API tokens. |
| 149 | +
|
| 150 | + 30 |
| 151 | + 00:01:43.900 --> 00:01:46.620 |
| 152 | + You will only see this option if you are a |
| 153 | + Superadmin. |
| 154 | +
|
| 155 | + 31 |
| 156 | + 00:01:46.620 --> 00:01:51.780 |
| 157 | + Select Create token. You can choose from |
| 158 | + predefined templates or build a custom token. |
| 159 | +
|
| 160 | + 32 |
| 161 | + 00:01:52.180 --> 00:01:55.660 |
| 162 | + For example, let's use the Edit Zone DNS |
| 163 | + template. |
| 164 | +
|
| 165 | + 33 |
| 166 | + 00:01:55.660 --> 00:02:00.260 |
| 167 | + Give your token a descriptive name such as |
| 168 | + DNS updates for example.com. |
| 169 | +
|
| 170 | + 34 |
| 171 | + 00:02:00.860 --> 00:02:04.500 |
| 172 | + The template will fulfill permissions, |
| 173 | + but you can adjust them as needed. |
| 174 | +
|
| 175 | + 35 |
| 176 | + 00:02:04.700 --> 00:02:06.620 |
| 177 | + Next assign permissions. |
| 178 | +
|
| 179 | + 36 |
| 180 | + 00:02:06.900 --> 00:02:12.190 |
| 181 | + Permissions are organized by account, |
| 182 | + user or zone and usually offer either read |
| 183 | +
|
| 184 | + 37 |
| 185 | + 00:02:12.190 --> 00:02:13.790 |
| 186 | + access or edit access. |
| 187 | +
|
| 188 | + 38 |
| 189 | + 00:02:13.830 --> 00:02:17.590 |
| 190 | + Edit allows full control, |
| 191 | + create, read, update, |
| 192 | +
|
| 193 | + 39 |
| 194 | + 00:02:17.590 --> 00:02:21.030 |
| 195 | + delete, and list, while read provides viewing |
| 196 | + rights only. |
| 197 | +
|
| 198 | + 40 |
| 199 | + 00:02:21.510 --> 00:02:24.510 |
| 200 | + Then select the resources the token applies |
| 201 | + to. |
| 202 | +
|
| 203 | + 41 |
| 204 | + 00:02:24.790 --> 00:02:30.510 |
| 205 | + For instance, granting zone DNS read access |
| 206 | + for example.com will let the token view DNS |
| 207 | +
|
| 208 | + 42 |
| 209 | + 00:02:30.510 --> 00:02:32.070 |
| 210 | + records for that zone only. |
| 211 | +
|
| 212 | + 43 |
| 213 | + 00:02:32.590 --> 00:02:36.070 |
| 214 | + If the token is used on a different zone, |
| 215 | + it will return an error. |
| 216 | +
|
| 217 | + 44 |
| 218 | + 00:02:36.550 --> 00:02:41.550 |
| 219 | + Optionally, you can add restrictions such as |
| 220 | + filtering by client IP or setting a time to |
| 221 | +
|
| 222 | + 45 |
| 223 | + 00:02:41.590 --> 00:02:43.110 |
| 224 | + live value for the token. |
| 225 | +
|
| 226 | + 46 |
| 227 | + 00:02:43.350 --> 00:02:46.190 |
| 228 | + Click continue to summary to review your |
| 229 | + selections. |
| 230 | +
|
| 231 | + 47 |
| 232 | + 00:02:46.430 --> 00:02:49.310 |
| 233 | + If everything looks correct, |
| 234 | + choose Create Token. |
| 235 | +
|
| 236 | + 48 |
| 237 | + 00:02:49.350 --> 00:02:52.150 |
| 238 | + The dashboard will now display your new token |
| 239 | + secret. |
| 240 | +
|
| 241 | + 49 |
| 242 | + 00:02:52.310 --> 00:02:54.910 |
| 243 | + Copy it immediately to a secure location. |
| 244 | +
|
| 245 | + 50 |
| 246 | + 00:02:54.950 --> 00:02:56.990 |
| 247 | + The secret is shown only once. |
| 248 | +
|
| 249 | + 51 |
| 250 | + 00:02:57.150 --> 00:03:00.230 |
| 251 | + Anyone with a token can perform the actions |
| 252 | + you've authorized, |
| 253 | +
|
| 254 | + 52 |
| 255 | + 00:03:00.230 --> 00:03:01.710 |
| 256 | + so treat it like a password. |
| 257 | +
|
| 258 | + 53 |
| 259 | + 00:03:02.030 --> 00:03:06.550 |
| 260 | + With that, you've successfully created an API |
| 261 | + token and can begin using it with a |
| 262 | +
|
| 263 | + 54 |
| 264 | + 00:03:06.550 --> 00:03:11.070 |
| 265 | + Cloudflare API. For more information, |
| 266 | + visit our developer documentation. |
0 commit comments