Para darles a los creadores de formularios más control sobre quiénes pueden responder, presentamos controles detallados para los usuarios que responden. Los formularios creados con la API después del 31 de enero de 2026 tendrán un estado no publicado de forma predeterminada. Para obtener más información, consulta
Cambios en la API de Formularios de Google.
Crear un formulario o cuestionario
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta página, se describe cómo realizar estas tareas relacionadas con los formularios:
- Crea un formulario nuevo
- Cómo duplicar un formulario existente
- Cómo convertir un formulario en un cuestionario
Antes de comenzar
Realiza las siguientes tareas antes de continuar con las tareas de esta página:
La creación inicial de un formulario solo requiere un campo de título. Se ignorarán todos los demás campos de la solicitud. Para compilar el contenido y los metadatos de un formulario o realizar actualizaciones, usa el método batchUpdate()
. Consulta Cómo actualizar un formulario o cuestionario para obtener más información.
REST
Llama al método forms.create()
con solo un título.
Cuerpo de la solicitud de muestra
{
"info": {
"title": "My new form"
}
}
Puedes duplicar un formulario existente con la API de Google Drive para facilitar la reutilización del contenido. Puedes encontrar el ID del formulario en una URL de Formularios de Google:
https://docs.google.com/forms/d/FORM_ID/edit
REST
Llama al método files.copy()
de la API de Google Drive
con el ID del formulario que deseas copiar.
Para crear un cuestionario, primero crea un formulario como se describe en Cómo crear un formulario nuevo y, luego, actualiza su configuración. La actualización requiere el ID del formulario.
REST
Llama al método batch.update()
en un formulario existente para establecer el parámetro isQuiz
como verdadero.
Cuerpo de la solicitud de muestra
{
"requests": [
{
"updateSettings": {
"settings": {
"quizSettings": {
"isQuiz": True
}
},
"updateMask": "quizSettings.isQuiz"
}
}
]
}
Próximos pasos
Estos son algunos pasos que puedes seguir:
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-06-27 (UTC)
[null,null,["Última actualización: 2025-06-27 (UTC)"],[],["This document details how to create, duplicate, and convert forms. To create a new form, use the `forms.create()` method with a title. To duplicate a form, employ the Drive API's `files.copy()` method, specifying the form's ID. To convert a form into a quiz, use the `batch.update()` method to change the `isQuiz` setting to true, also requires the form ID. Authorization and authentication setup as indicated in the instructions is required.\n"],null,["# Create a form or quiz\n\nThis page describes how to perform these tasks involving forms:\n\n- Create a new form\n- Duplicate an existing form\n- Convert a form to a quiz\n\nBefore you begin\n----------------\n\nDo the following tasks before proceeding with the tasks on this page:\n\n- Complete authorization or authentication and credentials setup in the Early Adopter Program instructions.\n- Read the [Forms API overview](/workspace/forms/api/guides).\n\nCreate a new form\n-----------------\n\nThe initial creation of a form only requires a title field---any other fields\nin the request will be ignored. To build out the content and metadata of a\nform or make updates, use the `batchUpdate()` method. See\n[Update a form or quiz](/workspace/forms/api/guides/update-form-quiz) for more\ninformation. \n\n### REST\n\nCall the [`forms.create()`](/workspace/forms/api/reference/rest/v1/forms/create)\nmethod with only a title.\n\n**Sample request body** \n\n {\n \"info\": {\n \"title\": \"My new form\"\n }\n }\n\n### Python\n\nforms/snippets/create_form.py \n[View on GitHub](https://github.com/googleworkspace/python-samples/blob/main/forms/snippets/create_form.py) \n\n```python\nfrom apiclient import discovery\nfrom httplib2 import Http\nfrom oauth2client import client, file, tools\n\nSCOPES = \"https://www.googleapis.com/auth/drive\"\nDISCOVERY_DOC = \"https://forms.googleapis.com/$discovery/rest?version=v1\"\n\nstore = file.Storage(\"token.json\")\ncreds = None\nif not creds or creds.invalid:\n flow = client.flow_from_clientsecrets(\"client_secrets.json\", SCOPES)\n creds = tools.run_flow(flow, store)\n\nform_service = discovery.build(\n \"forms\",\n \"v1\",\n http=creds.authorize(Http()),\n discoveryServiceUrl=DISCOVERY_DOC,\n static_discovery=False,\n)\n\nform = {\n \"info\": {\n \"title\": \"My new form\",\n },\n}\n# Prints the details of the sample form\nresult = form_service.forms().create(body=form).execute()\nprint(result)\n```\n\n### Node.js\n\nforms/snippets/create_form.js \n[View on GitHub](https://github.com/googleworkspace/node-samples/blob/main/forms/snippets/create_form.js) \n\n```javascript\n'use strict';\n\nconst path = require('path');\nconst google = require('@googleapis/forms');\nconst {authenticate} = require('@google-cloud/local-auth');\n\nasync function runSample(query) {\n const authClient = await authenticate({\n keyfilePath: path.join(__dirname, 'credentials.json'),\n scopes: 'https://www.googleapis.com/auth/drive',\n });\n const forms = google.forms({\n version: 'v1',\n auth: authClient,\n });\n const newForm = {\n info: {\n title: 'Creating a new form in Node',\n },\n };\n const res = await forms.forms.create({\n requestBody: newForm,\n });\n console.log(res.data);\n return res.data;\n}\n\nif (module === require.main) {\n runSample().catch(console.error);\n}\nmodule.exports = runSample;\n```\n\nDuplicate an existing form\n--------------------------\n\nYou can duplicate an existing form with the\n[Google Drive API](/workspace/drive/api/v3/about-sdk) to make content re-use\neasier. You can find the form ID in a Google Forms URL:\n\n`https://docs.google.com/forms/d/FORM_ID/edit` \n\n### REST\n\nCall the Google Drive API's\n[`files.copy()`](/workspace/drive/v3/reference/files/copy)\nmethod with the ID of the form you want to copy.\n\n### Python\n\nforms/snippets/duplicate_form.py \n[View on GitHub](https://github.com/googleworkspace/python-samples/blob/main/forms/snippets/duplicate_form.py) \n\n```python\nimport os.path\n\nfrom google.auth.transport.requests import Request\nfrom google.oauth2.credentials import Credentials\nfrom google_auth_oauthlib.flow import InstalledAppFlow\nfrom googleapiclient.discovery import build\n\n# If modifying these scopes, delete the file token.json.\nSCOPES = [\"https://www.googleapis.com/auth/drive\"]\n\n\ndef main():\n \"\"\"Shows copy file example in Drive v3 API.\n Prints the name, id and other data of the copied file.\n \"\"\"\n creds = None\n if os.path.exists(\"token.json\"):\n creds = Credentials.from_authorized_user_file(\"token.json\", SCOPES)\n # If there are no (valid) credentials available, let the user log in.\n if not creds or not creds.valid:\n if creds and creds.expired and creds.refresh_token:\n creds.refresh(Request())\n else:\n flow = InstalledAppFlow.from_client_secrets_file(\n \"client_secrets.json\", SCOPES\n )\n creds = flow.run_local_server(port=0)\n # Save the credentials for the next run\n with open(\"token.json\", \"w\") as token:\n token.write(creds.to_json())\n\n service = build(\"drive\", \"v3\", credentials=creds)\n\n # Call the Drive v3 API\n origin_file_id = \"1ox-6vHFeKpC6mon-tL5ygBC8zpbTnTp76JCZdIg80hA\" # example ID\n copied_file = {\"title\": \"my_copy\"}\n results = (\n service.files().copy(fileId=origin_file_id, body=copied_file).execute()\n )\n print(results)\n\n\nif __name__ == \"__main__\":\n main()\n```\n\nConvert a form to a quiz\n------------------------\n\nTo create a quiz, first create a form as described in [Create a new form](#create_a_new_form),\nthen update the form's settings. The update requires the form ID. \n\n### REST\n\nCall the\n[`batch.update()`](/workspace/forms/api/reference/rest/v1/forms/batchUpdate)\nmethod on an existing form to set the `isQuiz` setting to true.\n\n**Sample request body** \n\n {\n \"requests\": [\n {\n \"updateSettings\": {\n \"settings\": {\n \"quizSettings\": {\n \"isQuiz\": True\n }\n },\n \"updateMask\": \"quizSettings.isQuiz\"\n }\n }\n ]\n }\n\n### Python\n\nforms/snippets/convert_form.py \n[View on GitHub](https://github.com/googleworkspace/python-samples/blob/main/forms/snippets/convert_form.py) \n\n```python\nfrom apiclient import discovery\nfrom httplib2 import Http\nfrom oauth2client import client, file, tools\n\nSCOPES = \"https://www.googleapis.com/auth/forms.body\"\nDISCOVERY_DOC = \"https://forms.googleapis.com/$discovery/rest?version=v1\"\n\nstore = file.Storage(\"token.json\")\ncreds = None\nif not creds or creds.invalid:\n flow = client.flow_from_clientsecrets(\"client_secrets.json\", SCOPES)\n creds = tools.run_flow(flow, store)\n\nform_service = discovery.build(\n \"forms\",\n \"v1\",\n http=creds.authorize(Http()),\n discoveryServiceUrl=DISCOVERY_DOC,\n static_discovery=False,\n)\n\nform = {\n \"info\": {\n \"title\": \"My new quiz\",\n }\n}\n\n# Creates the initial form\nresult = form_service.forms().create(body=form).execute()\n\n# JSON to convert the form into a quiz\nupdate = {\n \"requests\": [\n {\n \"updateSettings\": {\n \"settings\": {\"quizSettings\": {\"isQuiz\": True}},\n \"updateMask\": \"quizSettings.isQuiz\",\n }\n }\n ]\n}\n\n# Converts the form into a quiz\nquestion_setting = (\n form_service.forms()\n .batchUpdate(formId=result[\"formId\"], body=update)\n .execute()\n)\n\n# Print the result to see it's now a quiz\ngetresult = form_service.forms().get(formId=result[\"formId\"]).execute()\nprint(getresult)\n```\n\n### Node.js\n\nforms/snippets/convert_form.js \n[View on GitHub](https://github.com/googleworkspace/node-samples/blob/main/forms/snippets/convert_form.js) \n\n```javascript\n'use strict';\n\nconst path = require('path');\nconst google = require('@googleapis/forms');\nconst {authenticate} = require('@google-cloud/local-auth');\n\nasync function runSample(query) {\n const authClient = await authenticate({\n keyfilePath: path.join(__dirname, 'credentials.json'),\n scopes: 'https://www.googleapis.com/auth/drive',\n });\n const forms = google.forms({\n version: 'v1',\n auth: authClient,\n });\n const newForm = {\n info: {\n title: 'Creating a new form for batchUpdate in Node',\n },\n };\n const createResponse = await forms.forms.create({\n requestBody: newForm,\n });\n console.log('New formId was: ' + createResponse.data.formId);\n\n // Request body to convert form to a quiz\n const updateRequest = {\n requests: [\n {\n updateSettings: {\n settings: {\n quizSettings: {\n isQuiz: true,\n },\n },\n updateMask: 'quizSettings.isQuiz',\n },\n },\n ],\n };\n const res = await forms.forms.batchUpdate({\n formId: createResponse.data.formId,\n requestBody: updateRequest,\n });\n console.log(res.data);\n return res.data;\n}\n\nif (module === require.main) {\n runSample().catch(console.error);\n}\nmodule.exports = runSample;\n```\n\nNext steps\n----------\n\nHere are a few next steps you might try:\n\n- To add or update form content, refer to [Update a form or quiz](/workspace/forms/api/guides/update-form-quiz).\n- To view form information or responses, refer to [Retrieve forms and responses](/workspace/forms/api/guides/retrieve-forms-responses).\n- To publish the form and manage responders, refer to [Publish and manage responders](/workspace/forms/api/guides/publish-form)."]]