It's a simple vercel function which creates Content entries based on Asset data.
Fully configurable through query parameters.
- Run
vercelcli and answer the questions. - Set environment variables.
| Variable | Description |
|---|---|
| CONTENTFUL_SPACE_ID | https://www.contentful.com/help/spaces/find-space-id/ |
| CONTENTFUL_ENVIRONMENT_ID | Optional Next to search in the menu. master will be used if not defined |
| CONTENTFUL_MANAGEMENT_API_KEY | https://app.contentful.com/account/profile/cma_tokens |
| CONTENTFUL_HOOK_SECRET | Optional Your custom text to secure the endpoint |
| Parameter | Default | Description |
|---|---|---|
contentTypeToCreate |
required |
Content type api id which will be used for entry creation |
referenceField |
required |
Field which will reference created Asset. Can be a list of fields separated by , |
titleField |
optional |
Asset field title data will be put into this field for contentTypeToCreate. Can be a list of fields separated by , |
descriptionField |
optional |
Asset field description data will be put into this field for contentTypeToCreate. Can be a list of fields separated by , |
fileField |
optional |
Assetfilename will be put into this field for contentTypeToCreate. Can be a list of fields separated by , |
locale |
en-US |
Which locale to use when filling out the fields |
idSuffix |
-media |
Same asset id will be used for entry. Only difference is idSuffix |
- Go to you
masterenvironment - Click cog icon next to your profile avatar
- Select Webhooks menu entry
- Click
+ Add Webhookbutton - Fill in descriptive name
- Use POST method for URL. Use your vercel deployment URL as the root suffixed with
/api/createAssetand add parameters. For example:https://vercel-contentful-hook-tasks.vercel.app/api/createAsset?contentTypeToCreate=mediaImage&referenceField=image&titleField=alt,internalName&descriptionField=figcaption - For trigger - check
PublishonAssetrow in Content Events. - (Optional) If you have
CONTENTFUL_HOOK_SECRETconfigured- In
Headersclick+ Add secret headersbutton - For key use
authorizationand for value - same value configured inCONTENTFUL_HOOK_SECRETenvironment variable.
- In
- Ensure that for Payload
Use default payloadis selected. - Click save
If this project is deployed and everything is configured correctly - your content entry will be created once Asset is published.
