Skip to content

Commit f6c14a0

Browse files
karaggeorgeMatthew Sweeney
authored andcommitted
Platform API: Projects endpoints updates (#1405)
* Updates to the projects api docs * Remove replace project env vars endpoint * Remove bad closing tag
1 parent 8acfe09 commit f6c14a0

File tree

1 file changed

+145
-79
lines changed

1 file changed

+145
-79
lines changed

components/references-mdx/api/v2/endpoints/projects.mdx

Lines changed: 145 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Create a new project with the `name` request parameter. If the project already e
4242
<Code lang="json">{`{
4343
"id":"QmQKrt94KYKF3sDysJq19N87uMmE8Wicbt2GirePy1dH8U",
4444
"name":"a-project-name",
45-
"alias": [],
4645
"accountId":"K4amb7K9dAt5R2vBJWF32bmY",
4746
"updatedAt":1555413045188,
4847
"createdAt":1555413045188
@@ -79,7 +78,6 @@ Create a project with the `name` request parameter if it does not already exist.
7978
<Code lang="json">{`{
8079
"id":"QmQKrt94KYKF3sDysJq19N87uMmE8Wicbt2GirePy1dH8U",
8180
"name":"a-project-name",
82-
"alias": [],
8381
"accountId":"K4amb7K9dAt5R2vBJWF32bmY",
8482
"updatedAt":1555413045188,
8583
"createdAt":1555413045188
@@ -115,18 +113,20 @@ Get a list of all the projects you currently have under your account.
115113
{
116114
"id":"QmQKrt94KYKF3sDysJq19N8gvhmE8Wicbt2GirePy1dH8U",
117115
"name":"a-project-name",
118-
"alias": [],
119116
"accountId":"K4amb7K9dAt5R2vBJWF32bmY",
120117
"createdAt":1555413045188,
121-
"updatedAt":1555413045188
118+
"updatedAt":1555413045188,
119+
"targets": {},
120+
"latestDeployments": []
122121
},
123122
{
124123
"id":"QmRhxc9HAmRMcLvWhCAf2ALLctxZ4s4fwsM1D5kNM8PJuL",
125124
"name":"another-project-name",
126-
"alias": [],
127125
"accountId":"K4amb7K9dAt5R2vBJWF32bmY",
128126
"createdAt":1555072968396,
129-
"updatedAt":1555345633993
127+
"updatedAt":1555345633993,
128+
"targets": {},
129+
"latestDeployments": []
130130
}
131131
]
132132
`}</Code>
@@ -148,6 +148,20 @@ Get the information for a specific project by passing either the project `id` or
148148
| **id** | <HelpLink href="#api-basics/types">ID</HelpLink> | No | The unique project identifier. |
149149
| **name** | <HelpLink href="#api-basics/types">String</HelpLink> | No | The project name. |
150150

151+
#### Response Parameters
152+
153+
| Key | <HelpLink href="#api-basics/types" hasIcon>Type</HelpLink> | Description |
154+
| --------------------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
155+
| **id** | <HelpLink href="#api-basics/types">ID</HelpLink> | A string holding the unique ID of the project. |
156+
| **name** | <HelpLink href="#api-basics/types">String</HelpLink> | The name of the project. |
157+
| **alias** | <HelpLink href="#api-basics/types">List</HelpLink> | A list of production domains for the project. |
158+
| **accountId** | <HelpLink href="#api-basics/types">String</HelpLink> | The unique ID of the user or team the project belongs to. |
159+
| **createdAt** | <HelpLink href="#api-basics/types">Date</HelpLink> | A number containing the date when the project was created in milliseconds. |
160+
| **updatedAt** | <HelpLink href="#api-basics/types">Date</HelpLink> | A number containing the date when the project was updated in milliseconds. |
161+
| **env** | <HelpLink href="#api-basics/types">List</HelpLink> | A list of environment variables configured for the project. |
162+
| **targets** | <HelpLink href="#api-basics/types">Map</HelpLink> | An object which has a `production` key containing the production deployment object, if a production deployment exists |
163+
| **latestDeployments** | <HelpLink href="#api-basics/types">List</HelpLink> | A list of the latest deployments for the project |
164+
151165
##### Example Request
152166

153167
<Request url="https://api.zeit.co/v1/projects/a-project-name" auth />
@@ -157,10 +171,85 @@ Get the information for a specific project by passing either the project `id` or
157171
<Code lang="json">{`{
158172
"id":"QmQKrt94KYKF3sDysJq19N8gvhmE8Wicbt2GirePy1dH8U",
159173
"name":"a-project-name",
160-
"alias": [],
174+
"alias": [
175+
{
176+
"createdAt": 1555413045188,
177+
"domain": "foobar.com",
178+
"target": "PRODUCTION",
179+
"configuredBy": "A",
180+
"configuredChangedAt": 1555413045188
181+
}
182+
],
161183
"accountId":"K4amb7K9dAt5R2vBJWF32bmY",
162184
"createdAt":1555413045188,
163-
"updatedAt":1555413045188
185+
"updatedAt":1555413045188,
186+
"env": [
187+
{
188+
"key": "API_SECRET",
189+
"value": "@a-new-secret",
190+
"configurationId": null,
191+
"updatedAt": 1557241361455,
192+
"createdAt": 1557241361455
193+
}
194+
],
195+
"targets": {
196+
"production": {
197+
"alias": [
198+
"foobar.com"
199+
],
200+
"aliasAssigned": 1571239348998,
201+
"builds": [
202+
{
203+
"use": "@now/static",
204+
"src": "**"
205+
}
206+
],
207+
"createdAt": 1571239348998,
208+
"createdIn": "sfo1",
209+
"deploymentHostname": "a-project-name-rjtr4pz3f",
210+
"forced": false,
211+
"id": "dpl_89qyp1cskzkLrVicDaZoDbjyHuDJ",
212+
"meta": {},
213+
"plan": "unlimited",
214+
"private": true,
215+
"readyState": "READY",
216+
"requestedAt": 1571239348998,
217+
"target": "production",
218+
"teamId": null,
219+
"type": "LAMBDAS",
220+
"url": "a-project-name-rjtr4pz3f.now.sh",
221+
"userId": "K4amb7K9dAt5R2vBJWF32bmY"
222+
}
223+
},
224+
"latestDeployments": [
225+
{
226+
"alias": [
227+
"foobar.com"
228+
],
229+
"aliasAssigned": 1571239348998,
230+
"builds": [
231+
{
232+
"use": "@now/static",
233+
"src": "**"
234+
}
235+
],
236+
"createdAt": 1571239348998,
237+
"createdIn": "sfo1",
238+
"deploymentHostname": "a-project-name-rjtr4pz3f",
239+
"forced": false,
240+
"id": "dpl_89qyp1cskzkLrVicDaZoDbjyHuDJ",
241+
"meta": {},
242+
"plan": "unlimited",
243+
"private": true,
244+
"readyState": "READY",
245+
"requestedAt": 1571239348998,
246+
"target": "production",
247+
"teamId": null,
248+
"type": "LAMBDAS",
249+
"url": "a-project-name-rjtr4pz3f.now.sh",
250+
"userId": "K4amb7K9dAt5R2vBJWF32bmY"
251+
}
252+
]
164253
}`}</Code>
165254

166255
### Remove a Single Project
@@ -218,8 +307,9 @@ Retrieve the environment variables for a given project by passing the project `i
218307
{
219308
"key": "API_SECRET",
220309
"value": "@a-new-secret",
221-
"installationId": null,
222-
"updatedAt": 1557241361455
310+
"configurationId": null,
311+
"updatedAt": 1557241361455,
312+
"createdAt": 1557241361455
223313
}
224314
]`}</Code>
225315

@@ -256,6 +346,9 @@ Create a new environment variable for the project by passing the project `id` in
256346
<Request
257347
method="POST"
258348
url="https://api.zeit.co/v1/projects/QmXtXGhXF6mZQ5ete2AwbeV3zAS17wEj7LYM3LuQ3Y45FF/env"
349+
headers={{
350+
'Content-Type': 'application/json'
351+
}}
259352
auth
260353
body={{
261354
key: 'API_SECRET',
@@ -269,8 +362,9 @@ Create a new environment variable for the project by passing the project `id` in
269362
{
270363
"key": "API_SECRET",
271364
"value": "@a-new-secret",
272-
"installationId": null,
273-
"updatedAt": 1557241361455
365+
"configurationId": null,
366+
"updatedAt": 1557241361455,
367+
"createdAt": 1557241361455
274368
}
275369
]`}</Code>
276370

@@ -279,65 +373,10 @@ Create a new environment variable for the project by passing the project `id` in
279373
</Note>
280374

281375
<Note>
282-
The <InlineCode>installationId</InlineCode> depends on the token used to make
376+
The <InlineCode>configurationId</InlineCode> depends on the token used to make
283377
the request.
284378
</Note>
285379

286-
### Replace a Project Environment Variable
287-
288-
<Endpoint method="PUT" url="/v1/projects/:id/env" />
289-
290-
Set all environment variables for the project by passing the project `id` in the URL and an `env` map as a request parameter. Any env variable that is present in the project but not given in the payload will be removed.
291-
292-
<Note>
293-
For security, only secrets can be used for these environment variables.
294-
</Note>
295-
296-
<Note>
297-
Only deployments made after this call will receive the environment variables
298-
set.
299-
</Note>
300-
301-
#### URL Parameters
302-
303-
| Key | <HelpLink href="#api-basics/types" hasIcon>Type</HelpLink> | Required | Description |
304-
| ------ | ---------------------------------------------------------- | -------- | ------------------------------ |
305-
| **id** | <HelpLink href="#api-basics/types">ID</HelpLink> | Yes | The unique project identifier. |
306-
307-
#### Request Parameters
308-
309-
| Key | <HelpLink href="#api-basics/types" hasIcon>Type</HelpLink> | Required | Description |
310-
| ------- | ---------------------------------------------------------- | -------- | -------------------------------------- |
311-
| **env** | <HelpLink href="#api-basics/types">Map</HelpLink> | Yes | A set of secret environment variables. |
312-
313-
##### Example Request
314-
315-
<Request
316-
method="PUT"
317-
url="https://api.zeit.co/v1/projects/QmXtXGhXF6mZQ5ete2AwbeV3zAS17wEj7LYM3LuQ3Y45FF/env"
318-
auth
319-
body={{
320-
env: {
321-
API_SECRET: '@a-new-secret'
322-
}
323-
}}
324-
/>
325-
326-
##### Example Response
327-
328-
<Code lang="json">{`[
329-
{
330-
"key": "API_SECRET",
331-
"value": "@a-new-secret",
332-
"installationId": null,
333-
"updatedAt": 1557241361455
334-
}
335-
]`}</Code>
336-
337-
<Note>
338-
The response will include all environment variables for the project.
339-
</Note>
340-
341380
### Delete a Specific Environment Variable
342381

343382
<Endpoint method="DELETE" url="/v1/projects/:id/env/:key" />
@@ -372,7 +411,7 @@ Delete a specific environment variable for a given project by passing both the p
372411

373412
<Endpoint method="POST" url="/v1/projects/:id/alias" />
374413

375-
Add a domain to the project by passing the project `id` in the URL and `domain` as request parameters.
414+
Add a domain to the project by passing the project `id` in the URL and the `domain` and `redirect` as request parameters. If the domain already exists on the project, fails with `400` status code.
376415

377416
#### URL Parameters
378417

@@ -387,27 +426,49 @@ Add a domain to the project by passing the project `id` in the URL and `domain`
387426
| **domain** | <HelpLink href="#api-basics/types">String</HelpLink> | Yes | The name of the production domain. |
388427
| **redirect** | <HelpLink href="#api-basics/types">String</HelpLink> | No | Target destination domain for redirect |
389428

429+
<Note>You can only redirect to domains that belong to the project.</Note>
430+
390431
##### Example Request
391432

392433
<Request
393434
method="POST"
394435
url="https://api.zeit.co/v1/projects/QmXtXGhXF6mZQ5ete2AwbeV3zAS17wEj7LYM3LuQ3Y45FF/alias"
436+
headers={{
437+
'Content-Type': 'application/json'
438+
}}
395439
auth
396440
body={{
397441
domain: 'foobar.com',
398442
redirect: null
399443
}}
400444
/>
401445

402-
##### Example Response
446+
##### Example Response (successful)
403447

404448
<Code lang="json">{`[
405449
{
406450
"createdAt": 1562119110860,
407-
"domain": "foobar.com"
451+
"domain": "foobar.com",
452+
"target": "PRODUCTION",
453+
"configuredBy": "A",
454+
"configuredChangedAt": 1562119110860
408455
}
409456
]`}</Code>
410457

458+
##### Example response (unsuccessful)
459+
460+
<Code lang="json">{`{
461+
"error": {
462+
"code": "ALIAS_DOMAIN_EXIST",
463+
"domain": "foobar.com",
464+
"project": {
465+
"id": "QmXtXGhXF6mZQ5ete2AwbeV3zAS17wEj7LYM3LuQ3Y45FF",
466+
"name": "a-project-name",
467+
"accountId": "K4amb7K9dAt5R2vBJWF32bmY",
468+
}
469+
}
470+
}`}</Code>
471+
411472
<Note>
412473
The response will include all production domains configured for the project.
413474
</Note>
@@ -432,13 +493,14 @@ Set redirect from specified domain to a different domain in the same project (st
432493

433494
#### Request Parameters
434495

435-
| Key | <HelpLink href="#api-basics/types" hasIcon>Type</HelpLink> | Required | Description |
436-
| ------------ | ---------------------------------------------------------- | -------- | -------------------------------------- |
437-
| **domain** | <HelpLink href="#api-basics/types">String</HelpLink> | Yes | The name of the production domain. |
496+
| Key | <HelpLink href="#api-basics/types" hasIcon>Type</HelpLink> | Required | Description |
497+
| ------------ | ---------------------------------------------------------- | -------- | --------------------------------------- |
498+
| **domain** | <HelpLink href="#api-basics/types">String</HelpLink> | Yes | The name of the production domain. |
438499
| **redirect** | <HelpLink href="#api-basics/types">String</HelpLink> | No | Target destination domain for redirect. |
439500

440-
<Example>
441-
<span>Example request:</span>
501+
<Note>You can only redirect to domains that belong to the project.</Note>
502+
503+
##### Example Request
442504

443505
<Request
444506
method="PATCH"
@@ -450,14 +512,13 @@ Set redirect from specified domain to a different domain in the same project (st
450512
}}
451513
/>
452514

453-
Example response:
515+
##### Example response:
454516

455517
<Code lang="json">{`[
456518
{
457519
"createdAt": 1571138625066,
458520
"domain": "foobar.com",
459521
"target": "PRODUCTION",
460-
"redirect": null,
461522
"configuredBy": "A",
462523
"configuredChangedAt": 1571945629322
463524
},
@@ -470,7 +531,6 @@ Example response:
470531
"configuredChangedAt": 1571945629501
471532
}
472533
]`}</Code>
473-
</Example>
474534

475535
<Note>
476536
The response will include all production domains configured for the project.
@@ -499,6 +559,12 @@ Delete a specific production domain configuration from a project by passing the
499559
| ------ | ---------------------------------------------------------- | -------- | ------------------------------ |
500560
| **id** | <HelpLink href="#api-basics/types">ID</HelpLink> | Yes | The unique project identifier. |
501561

562+
#### Query Parameters
563+
564+
| Key | <HelpLink href="#api-basics/types" hasIcon>Type</HelpLink> | Required | Description |
565+
| ---------- | ---------------------------------------------------------- | -------- | ---------------------------------- |
566+
| **domain** | <HelpLink href="#api-basics/types">String</HelpLink> | Yes | The name of the production domain. |
567+
502568
##### Example Request
503569

504570
<Request

0 commit comments

Comments
 (0)