{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/pt/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Operações assíncronas"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"operações-assíncronas","__idx":0},"children":["Operações assíncronas"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Algumas operações do MoreLogin aceitam o trabalho antes de o navegador, Cloud Phone, arquivo, aplicativo ou execução de RPA subjacente atingir o estado final. Uma resposta de envio bem-sucedida significa que a requisição foi aceita; não significa sempre que o estado solicitado já foi alcançado."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"modelo-de-estados-do-cliente","__idx":1},"children":["Modelo de estados do cliente"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Estado"},"children":["Estado"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Significado"},"children":["Significado"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Ação do cliente"},"children":["Ação do cliente"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Enviado"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A API aceitou o comando ou criou uma tarefa"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Guarde os IDs retornados e o ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requestId"]},"; não reenvie a mesma escrita imediatamente"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Pendente ou em execução"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A operação posterior ainda está em andamento"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Consulte o endpoint documentado de status/resultado com intervalos crescentes"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Bem-sucedido"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["O recurso ou a tarefa alcançou seu estado terminal de êxito"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Pare de consultar e continue o fluxo"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Falhou"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["O endpoint de status/resultado informa falha ou um erro de negócio terminal"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Pare as novas tentativas automáticas; guarde os IDs, os detalhes da falha e o ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requestId"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resultado desconhecido"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A escrita expirou ou a conexão fechou sem uma resposta utilizável"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Consulte o estado atual do recurso ou da tarefa antes de decidir repetir"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"regras-de-polling","__idx":2},"children":["Regras de polling"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Comece por cerca de 1 segundo e aumente o intervalo para 2, 4 e 8 segundos, com limite de 15–30 segundos."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Aplique jitter para que clientes concorrentes não consultem no mesmo instante."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Pare em um estado terminal documentado; não faça polling indefinidamente."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Interprete ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data: null"]}," como pendente apenas quando o endpoint documentar esse comportamento explicitamente."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Um tempo limite de transporte em uma escrita não é prova de falha."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"fluxos-documentados","__idx":3},"children":["Fluxos documentados"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Fluxo"},"children":["Fluxo"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Operação de envio"},"children":["Operação de envio"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Operação de observação"},"children":["Operação de observação"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Estado terminal"},"children":["Estado terminal"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Início/parada do cloud browser"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudbrowser/start"]}," ou ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/cloudbrowser/stop"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudbrowser/page"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["O runtime alcança o estado pretendido ou desaparece após a parada"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Ligar/desligar Cloud Phone"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/powerOn"]}," ou ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/cloudphone/powerOff"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/page"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["envStatus=4"]}," ligado ou ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["envStatus=2"]}," desligado; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["1"]}," é falha de criação"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Upload de arquivo no Cloud Phone"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Envie para a URL assinada e depois ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/uploadFile"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/uploadFileResult"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status=1"]}," êxito ou ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status=2"]}," falha; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data: null"]}," e ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status=0"]}," são pendentes"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Download do Cloud Phone"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/download"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/download/result"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status=20"]}," êxito, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["30"]}," falha ou ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["40"]}," cancelado; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["10"]}," é em execução"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Instalação de aplicativo"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/app/install"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/app/installedList"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["O pacote solicitado aparece na lista de aplicativos instalados"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Agendamento/execução de RPA"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/rpa/task/save"]}," ou ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/onceTask/save"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/rpa/task/page"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/subTask/page"]}," e ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/subTask/detail/{id}"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["taskState=2"]}," concluído ou ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["3"]}," cancelado; verifique ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["handleResult"]}," (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0"]}," falha, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["1"]}," êxito)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Transmissão ao vivo"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/live/start"]}," ou ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/live/end"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/live/status"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["O status confirma que a transmissão começou ou parou"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Upload para cloud storage"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudstorage/upload/init"]},", seguido do ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," no object store"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudstorage/upload/complete"]}," depois que cada PUT necessário tiver êxito"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A resposta de conclusão tem êxito; nunca chame complete antes de o upload do objeto ter êxito"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Os equivalentes da Local API usam o prefixo ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api"]}," onde documentado. Veja a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/pt/api-reference/getting-started/endpoint-behavior"},"children":["Matriz de novas tentativas e conclusão de endpoints"]}," para orientação operação por operação."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"exemplo-de-recuperação-após-tempo-limite","__idx":4},"children":["Exemplo de recuperação após tempo limite"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"try:\n    submit_operation()\nexcept TimeoutError:\n    # The write may already have succeeded.\n    current = query_current_state()\n    if current.is_terminal_success:\n        pass\n    elif current.is_pending:\n        poll_until_terminal()\n    else:\n        decide_whether_retry_is_safe(current)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A API pública não define atualmente um cabeçalho geral de chave de idempotência. Por isso IDs de recurso, IDs de tarefa, consultas de estado e o ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requestId"]}," são essenciais para uma recuperação segura."]}]},"headings":[{"value":"Operações assíncronas","id":"operações-assíncronas","depth":1},{"value":"Modelo de estados do cliente","id":"modelo-de-estados-do-cliente","depth":2},{"value":"Regras de polling","id":"regras-de-polling","depth":2},{"value":"Fluxos documentados","id":"fluxos-documentados","depth":2},{"value":"Exemplo de recuperação após tempo limite","id":"exemplo-de-recuperação-após-tempo-limite","depth":2}],"frontmatter":{"seo":{"title":"Operações assíncronas"}},"lastModified":"2026-09-03T05:46:01.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/pt/api-reference/getting-started/async-operations","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}