Search code examples
smartsheet-api

How to get ID of smartsheet column, either manually via UI, or through a fetch-request


I am using smartsheet for a project. By accessing File>Properties, the sheet ID is displayed. The same is true for Row ID, when highlighting a row. However, none of these standard UI methods work for columns.

How is one able to see column ID in smartsheet?


Solution

  • I'm not aware of a way to get Column Ids via the Smartsheet UI. However, you can easily do so via API.

    If you execute the Get Sheet operation, the response will be a Sheet object that contains (amongst other things), a columns property that is an array of Column objects that represent the columns the Sheet contains.

    Request: GET /sheets/{sheetId}

    Response (partial):

    {
      "id": 4583173393803140,
      ...
      "columns": [
        {
          "id": 4583173393803140,
          "version": 1,
          "index": 0,
          "primary": true,
          "title": "Item",
          "type": "TEXT_NUMBER",
          "validation": false
        },
        {
          "id": 603843458295684,
          "version": 2,
          "index": 5,
          "title": "Type",
          "type": "TEXT_NUMBER"
          "validation": false
        },
        ...
      ],
      "rows": [...]
    }
    
    

    If this is a one-time task for you, you could use either cURL or the Postman API Client to submit the Get Sheet request. Otherwise -- i.e., if getting Column Ids is part of a larger integration you're developing -- you can issue the Get Sheet request using the language of your choice.

    UPDATE 12/8 (List Columns):

    Another way to get information about the columns a sheet contains would be to use the List Columns operation. This would be more efficient than using the Get Sheet operation, since the response for List Columns only contains column information, whereas the response for Get Sheet contains row information as well (in addition to other sheet-level properties).

    Request: GET /sheets/{sheetId}/columns

    Response (example, for a sheet with 3 columns):

    {
      "pageNumber": 1,
      "pageSize": 100,
      "totalPages": 1,
      "totalCount": 3,
        "data": [
            {
                "id": 7960873114331012,
                "index": 0,
                "symbol": "STAR",
                "title": "Favorite",
                "type": "CHECKBOX",
                "validation": false
            },
            {
                "id": 642523719853956,
                "index": 1,
                "primary": true,
                "title": "Primary Column",
                "type": "TEXT_NUMBER",
                "validation": false
            },
            {
                "id": 5146123347224452,
                "index": 2,
                "title": "Status",
                "type": "PICKLIST",
                "validation": false
            }
        ]
    }